From 366a748549914f6c9880433ad98e30face57c7ab Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sat, 22 Aug 2026 17:08:03 +1000 Subject: [PATCH] [client] pipewire: honor playback quantum Do not treat the capacity of an allocated PipeWire buffer as the requested playback period when PipeWire supplies no per-buffer hint. Use the current stream quantum when available and fall back to the configured period. --- client/audiodevs/PipeWire/pipewire.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/client/audiodevs/PipeWire/pipewire.c b/client/audiodevs/PipeWire/pipewire.c index 62d77367..d4247785 100644 --- a/client/audiodevs/PipeWire/pipewire.c +++ b/client/audiodevs/PipeWire/pipewire.c @@ -494,7 +494,8 @@ static void pipewire_onPlaybackProcess(void * userdata) return; } - int frames = sbuf->datas[0].maxsize / pw.playback.stride; + int frames = + sbuf->datas[0].maxsize / pw.playback.stride; struct spa_io_rate_match * rateMatch = atomic_load_explicit( &pw.playback.rateMatch, memory_order_acquire); if (rateMatch && rateMatch->size > 0) @@ -503,6 +504,17 @@ static void pipewire_onPlaybackProcess(void * userdata) else if (pbuf->requested > 0) frames = min(frames, pbuf->requested); #endif + else + { +#if PW_CHECK_VERSION(1, 1, 0) + struct pw_time time = {0}; + if (pw_stream_get_time_n( + pw.playback.stream, &time, sizeof(time)) >= 0 && time.size > 0) + frames = (int)min((uint64_t)frames, time.size); + else +#endif + frames = min(frames, pw.playback.maxPeriodFrames); + } const int requestedFrames = frames; frames = pw.playback.pullFn(dst, requestedFrames);