Skip to content

Commit

Permalink
fix flush mode
Browse files Browse the repository at this point in the history
  • Loading branch information
philippe44 committed Dec 28, 2023
1 parent 5c90086 commit 9679c5c
Show file tree
Hide file tree
Showing 19 changed files with 33 additions and 9 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
8 changes: 5 additions & 3 deletions components/spotify/cspot/bell/external/mdnssvc/climdnssvc.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,15 @@ int main(int argc, char *argv[]) {
} else if (!strcasecmp(arg, "-i")) {
identity = *++argv;
} else {
// nothing let's try to be smart and handle legacy crappy
// nothing let's try to be smart and handle legacy crap
if (!identity) identity = *argv;
else if (!type) (void) !asprintf(&type, "%s.local", *argv);
else if (!port) port = atoi(*argv);
else {
txt = (const char**) malloc((argc + 1) * sizeof(char**));
memcpy(txt, argv, argc * sizeof(char**));
txt[argc] = NULL;
break;
}
argc--;
}
Expand All @@ -250,21 +251,22 @@ int main(int argc, char *argv[]) {

mdnsd_set_hostname(svr, hostname, host);
svc = mdnsd_register_svc(svr, identity, type, port, NULL, txt);
mdns_service_destroy(svc);
// mdns_service_destroy(svc);

#ifdef _WIN32
Sleep(INFINITE);
#else
pause();
#endif
mdns_service_remove(svr, svc);
mdnsd_stop(svr);
} else {
printf("Can't start server");
print_usage();
}

free(type);
free(txt);
if (txt) free(txt);

#ifdef _WIN32
winsock_close();
Expand Down
7 changes: 3 additions & 4 deletions components/spotify/cspot/bell/external/mdnssvc/mdnsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,10 @@ static int create_recv_sock(uint32_t host) {
}

#if !defined(_WIN32)
on = sizeof(on);
socklen_t len;
if (!getsockopt(sd, SOL_SOCKET, SO_REUSEPORT,(char*) &on, &len)) {
socklen_t len = sizeof(on);
if (!getsockopt(sd, SOL_SOCKET, SO_REUSEPORT, &on, &len)) {
on = 1;
if ((r = setsockopt(sd, SOL_SOCKET, SO_REUSEPORT,(char*) &on, sizeof(on))) < 0) {
if ((r = setsockopt(sd, SOL_SOCKET, SO_REUSEPORT, &on, sizeof(on))) < 0) {
log_message(LOG_ERR, "recv setsockopt(SO_REUSEPORT): %m\n", r);
}
}
Expand Down
14 changes: 13 additions & 1 deletion components/squeezelite/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ void output_close_common(void) {
}

void output_flush(void) {
LOG_INFO("flush output buffer");
LOG_INFO("flush output buffer (full)");
buf_flush(outputbuf);
LOCK;
output.fade = FADE_INACTIVE;
Expand All @@ -457,3 +457,15 @@ void output_flush(void) {
output.frames_played = 0;
UNLOCK;
}

bool output_flush_streaming(void) {
LOG_INFO("flush output buffer (streaming)");
LOCK;
bool flushed = output.track_start != NULL;
if (output.track_start) {
outputbuf->writep = output.track_start;
output.track_start = NULL;
}
UNLOCK;
return flushed;
}
12 changes: 11 additions & 1 deletion components/squeezelite/slimproto.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,18 @@ static void process_strm(u8_t *pkt, int len) {
sendSTAT("STMt", strm->replay_gain); // STMt replay_gain is no longer used to track latency, but support it
break;
case 'f':
{
decode_flush(false);
bool flushed = false;
if (!output.external) flushed |= output_flush_streaming();
// we can have fully finished the current streaming, that's still a flush
if (stream_disconnect() || flushed) sendSTAT("STMf", 0);
buf_flush(streambuf);
output.stop_time = gettime_ms();
break;
}
case 'q':
decode_flush(strm->command == 'q');
decode_flush(true);
if (!output.external) output_flush();
status.frames_played = 0;
if (stream_disconnect() && strm->command == 'f') sendSTAT("STMf", 0);
Expand Down
1 change: 1 addition & 0 deletions components/squeezelite/squeezelite.h
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,7 @@ struct outputstate {
void output_init_common(log_level level, const char *device, unsigned output_buf_size, unsigned rates[], unsigned idle);
void output_close_common(void);
void output_flush(void);
bool output_flush_streaming(void);
// _* called with mutex locked
frames_t _output_frames(frames_t avail);
void _checkfade(bool);
Expand Down

0 comments on commit 9679c5c

Please sign in to comment.