From d11f5331fe3c63dcd9623ade54db880fc172f2dc Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Fri, 11 Sep 2026 02:36:35 +0200 Subject: [PATCH] Stamp live audio with the receive clock The producer's presentation ticks start at zero per session and sit in its clock domain; handed to the mixer they read as ever-growing drift, and OBS kept adding buffering and restarting the source's audio for lagging. OBS's own network sources stamp with the receive clock; so does this one. Co-Authored-By: Claude Fable 5.1 --- plugin/src/ratatoskr_source.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugin/src/ratatoskr_source.c b/plugin/src/ratatoskr_source.c index d69c8db..2613513 100644 --- a/plugin/src/ratatoskr_source.c +++ b/plugin/src/ratatoskr_source.c @@ -166,8 +166,13 @@ static void create_video_child(struct ratatoskr_source *ctx) obs_source_add_active_child(ctx->source, ctx->video_child); } +/* Live audio is stamped with the receive clock, as OBS's own network sources + * do. The producer's presentation ticks start at zero per session and sit in + * its clock domain; handing them to the mixer read as ever-growing drift and + * OBS kept adding buffering, then restarted the source's audio for lagging. */ static void output_audio(struct ratatoskr_source *ctx, const uint8_t *pcm, size_t len, int64_t pts_ns) { + UNUSED_PARAMETER(pts_ns); if (ctx->audio_channels == 0 || ctx->audio_sample_rate == 0) return; size_t frame_bytes = sizeof(float) * ctx->audio_channels; @@ -179,7 +184,7 @@ static void output_audio(struct ratatoskr_source *ctx, const uint8_t *pcm, size_ audio.samples_per_sec = ctx->audio_sample_rate; audio.format = AUDIO_FORMAT_FLOAT; audio.speakers = ctx->audio_channels == 1 ? SPEAKERS_MONO : SPEAKERS_STEREO; - audio.timestamp = pts_ns > 0 ? (uint64_t)pts_ns : os_gettime_ns(); + audio.timestamp = os_gettime_ns(); obs_source_output_audio(ctx->source, &audio); }