summaryrefslogtreecommitdiff
path: root/src/libsink
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsink')
-rw-r--r--src/libsink/sink.c29
1 files changed, 20 insertions, 9 deletions
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) {