From d6735566cebf82a5d22a3ade22b9acd52fbe11a5 Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Sun, 27 Oct 2024 19:58:31 -0400 Subject: Buffer tweaks Signed-off-by: Andrew Opalach --- src/libsink/sink.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'src/libsink') diff --git a/src/libsink/sink.c b/src/libsink/sink.c index a2262bc..ff9f4f2 100644 --- a/src/libsink/sink.c +++ b/src/libsink/sink.c @@ -468,18 +468,17 @@ static void video_buffer_callback(void *userdata, u8 op) static void evaluate_latency(struct camu_sink *sink, struct camu_sink_entry *entry) { - // Entry has both audio and video configured. +#if CAMU_SINK_LOCAL #ifndef CAMU_SINK_NO_VIDEO + // Entry has both audio and video configured. if (!BUFFER_EMPTY(&entry->audio) && !BUFFER_EMPTY(&entry->video)) { camu_video_buffer_set_latency(&entry->video.buf, -camu_mixer_get_latency(sink->audio.mixer)); - } else if (!BUFFER_EMPTY(&entry->audio)) { -#if !CAMU_SINK_LOCAL - camu_audio_buffer_set_latency(&entry->audio.buf, -camu_mixer_get_latency(sink->audio.mixer)); -#endif } +#endif #else - (void)sink; - (void)entry; + // To sync clients with differing audio latencies our only option is to factor the mixer + // latency into the audio buffer. + camu_audio_buffer_set_latency(&entry->audio.buf, camu_mixer_get_latency(sink->audio.mixer)); #endif } @@ -867,8 +866,16 @@ static bool set_command_callback(void *userdata, struct aki_rpc_connection *conn set_or_queue_entry(entry); sink->current = entry; break; - case LIANA_PAUSE_PAUSE: - if (sink->current) { + case LIANA_PAUSE_PAUSE: { + struct camu_sink_entry *prev_target = sink->target; + if (prev_target) { + if (prev_target == entry) { + sink->target = NULL; + } else { + sink->target = entry; + } + camu_clock_pause(&prev_target->clock, at); + } else if (sink->current) { if (camu_clock_is_ended(&sink->current->clock)) { // Server thought we weren't done, be we are. switch_to(sink, entry); @@ -878,6 +885,7 @@ static bool set_command_callback(void *userdata, struct aki_rpc_connection *conn } } break; + } case LIANA_PAUSE_BOTH: { camu_clock_resume(&entry->clock, at); struct camu_sink_entry *prev_target = sink->target; @@ -928,6 +936,9 @@ static bool pause_command_callback(void *userdata, struct aki_rpc_connection *co if (!current) goto out; #if CAMU_SINK_LOCAL + (void)sequence; + (void)at; + (void)pause; sink_local_pause(sink, current); #else if (current->sequence == sequence) { -- cgit v1.2.3-101-g0448