From 965a50b2e7d42b4cfb5deca0c05cfb30f4ade038 Mon Sep 17 00:00:00 2001 From: dimtpap Date: Tue, 3 Sep 2024 08:44:21 +0300 Subject: [PATCH] Use received frames for period calculation out.frames was clock.duration at some point but it changed, and this didn't --- src/pipewire-audio.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pipewire-audio.c b/src/pipewire-audio.c index 7149338..bdf1f48 100644 --- a/src/pipewire-audio.c +++ b/src/pipewire-audio.c @@ -206,8 +206,7 @@ static void on_process_cb(void *data) * (https://gitlab.freedesktop.org/pipewire/pipewire/-/blob/0.3.52/pipewire-jack/src/pipewire-jack.c#L5639) * which is used in the linux-jack plugin to correctly set the timestamp * (https://github.com/obsproject/obs-studio/blob/27.2.4/plugins/linux-jack/jack-wrapper.c#L87) */ - double period_nsecs = - s->pos->clock.duration * (double)SPA_NSEC_PER_SEC / (s->info.sample_rate * s->pos->clock.rate_diff); + double period_nsecs = out.frames * (double)SPA_NSEC_PER_SEC / (s->info.sample_rate * s->pos->clock.rate_diff); out.timestamp = now - (uint64_t)period_nsecs; } else {