From 7c9f4f7e4f65aa8460ab5e585c67933149c3b01c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 10 Aug 2021 10:50:33 +0200 Subject: [PATCH] output/pipewire: create inactive stream, fill ring_buffer first This avoids underruns at the start of playback. --- src/output/plugins/PipeWireOutputPlugin.cxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/output/plugins/PipeWireOutputPlugin.cxx b/src/output/plugins/PipeWireOutputPlugin.cxx index 82ea5cbbb..37a81d2ad 100644 --- a/src/output/plugins/PipeWireOutputPlugin.cxx +++ b/src/output/plugins/PipeWireOutputPlugin.cxx @@ -336,7 +336,13 @@ PipeWireOutput::Open(AudioFormat &audio_format) { disconnected = false; restore_volume = true; - paused = false; + + /* we're paused (inactive) now because of the flag + PW_STREAM_FLAG_INACTIVE; this way, we can fill the + ring_buffer before activating the stream, to avoid + underruns */ + paused = true; + drain_requested = false; drained = true; @@ -380,6 +386,7 @@ PipeWireOutput::Open(AudioFormat &audio_format) PW_DIRECTION_OUTPUT, target_id, (enum pw_stream_flags)(PW_STREAM_FLAG_AUTOCONNECT | + PW_STREAM_FLAG_INACTIVE | PW_STREAM_FLAG_MAP_BUFFERS | PW_STREAM_FLAG_RT_PROCESS), params, 1);