mpd: Backport PipeWire output fixes
[AGL/meta-agl-demo.git] / recipes-multimedia / musicpd / files / 0004-output-PipeWire-after-Cancel-refill-buffer-before-re.patch
1 From c8dae95eff60419fdff88d55400b6cbaacac137d Mon Sep 17 00:00:00 2001
2 From: Max Kellermann <max.kellermann@gmail.com>
3 Date: Sat, 9 Jul 2022 00:59:35 +0200
4 Subject: [PATCH] output/PipeWire: after Cancel(), refill buffer before
5  resuming playback
6
7 Deactivate the stream in Cancel().  This fixes stuttering after a
8 manual song change by refilling the whole ring buffer before
9 reactivating the stream.
10
11 Closes https://github.com/MusicPlayerDaemon/MPD/issues/1354
12
13 Upstream-Status: Backport [https://github.com/MusicPlayerDaemon/MPD/commit/c8dae95eff60419fdff88d55400b6cbaacac137d]
14 Signed-off-by: Scott Murray <scott.murray@konsulko.com>
15
16 ---
17 diff --git a/src/output/plugins/PipeWireOutputPlugin.cxx b/src/output/plugins/PipeWireOutputPlugin.cxx
18 index 0f8550d41..16febe909 100644
19 --- a/src/output/plugins/PipeWireOutputPlugin.cxx
20 +++ b/src/output/plugins/PipeWireOutputPlugin.cxx
21 @@ -901,6 +901,15 @@ PipeWireOutput::Cancel() noexcept
22         /* clear libpipewire's buffer */
23         pw_stream_flush(stream, false);
24         drained = true;
25 +
26 +       /* pause the PipeWire stream so libpipewire ceases invoking
27 +          the "process" callback (we have no data until our Play()
28 +          method gets called again); the stream will be resume by
29 +          Play() after the ring_buffer has been refilled */
30 +       if (active) {
31 +               active = false;
32 +               pw_stream_set_active(stream, false);
33 +       }
34  }
35  
36  bool
37 -- 
38 2.39.0
39