diff options
| author | 2024-10-28 13:08:13 -0400 | |
|---|---|---|
| committer | 2024-10-28 13:23:02 -0400 | |
| commit | 846e17728f2ed2af3672987ef61853f0bc96c224 (patch) | |
| tree | e8e81fc8a2a7de208bd9ba397ef3928d33110824 /src/libsink | |
| parent | d6735566cebf82a5d22a3ade22b9acd52fbe11a5 (diff) | |
| download | camu-846e17728f2ed2af3672987ef61853f0bc96c224.tar.gz camu-846e17728f2ed2af3672987ef61853f0bc96c224.tar.bz2 camu-846e17728f2ed2af3672987ef61853f0bc96c224.zip | |
Refactor video buffer and scaler, better A/V sync
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'src/libsink')
| -rw-r--r-- | src/libsink/sink.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/libsink/sink.c b/src/libsink/sink.c index ff9f4f2..da8f47f 100644 --- a/src/libsink/sink.c +++ b/src/libsink/sink.c @@ -472,13 +472,20 @@ static void evaluate_latency(struct camu_sink *sink, struct camu_sink_entry *ent #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)); + f64 audio = camu_mixer_get_latency(sink->audio.mixer); + s32 frames = audio / entry->video.buf.avg_frame_duration; + frames -= sink->video.renderer->get_latency(sink->video.renderer); + camu_video_buffer_set_latency(&entry->video.buf, -frames); } #endif #else // 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)); + // latency directly into the audio buffer. + f64 audio = camu_mixer_get_latency(sink->audio.mixer); + s32 frames = audio / entry->video.buf.avg_frame_duration; + frames += sink->video.renderer->get_latency(sink->video.renderer); + camu_video_buffer_set_latency(&entry->video.buf, frames); + camu_audio_buffer_set_latency(&entry->audio.buf, audio); #endif } @@ -823,6 +830,8 @@ static bool set_command_callback(void *userdata, struct aki_rpc_connection *conn entry->ended = ended; + if (entry == sink->current) goto out; + if (op == LIANA_SINK_BUFFER) { goto out; } else if (op == LIANA_SINK_BUFFER_AND_QUEUE) { |