[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.
This commit is contained in:
Geoffrey McRae
2026-08-22 17:08:03 +10:00
parent ebf764ae25
commit 366a748549

View File

@@ -494,7 +494,8 @@ static void pipewire_onPlaybackProcess(void * userdata)
return; 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( struct spa_io_rate_match * rateMatch = atomic_load_explicit(
&pw.playback.rateMatch, memory_order_acquire); &pw.playback.rateMatch, memory_order_acquire);
if (rateMatch && rateMatch->size > 0) if (rateMatch && rateMatch->size > 0)
@@ -503,6 +504,17 @@ static void pipewire_onPlaybackProcess(void * userdata)
else if (pbuf->requested > 0) else if (pbuf->requested > 0)
frames = min(frames, pbuf->requested); frames = min(frames, pbuf->requested);
#endif #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; const int requestedFrames = frames;
frames = pw.playback.pullFn(dst, requestedFrames); frames = pw.playback.pullFn(dst, requestedFrames);