From aa33c2841cabe1d584fe15d7eda6952ad50467bd Mon Sep 17 00:00:00 2001 From: Marcin Radomski Date: Tue, 10 May 2022 20:29:04 +0200 Subject: [PATCH] pulse-server: avoid skipping more ringbuffer data than available This prevents the ringbuffer from advancing the read pointer more than the size of data actually available. It prevents the "avail" value from keeping to drop when no audio is being played by the client. Applying this patch seems to prevent the "randomly playing music after a couple hours of silence" issue Fixes #2366 --- src/modules/module-protocol-pulse/pulse-server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/module-protocol-pulse/pulse-server.c b/src/modules/module-protocol-pulse/pulse-server.c index fd249562b..22858c03d 100644 --- a/src/modules/module-protocol-pulse/pulse-server.c +++ b/src/modules/module-protocol-pulse/pulse-server.c @@ -1288,10 +1288,10 @@ static void stream_process(void *data) stream->buffer, MAXLENGTH, index % MAXLENGTH, p, avail); + index += avail; } pd.playing_for = size; pd.read_inc = size; - index += size; spa_ringbuffer_read_update(&stream->ring, index); } pw_log_debug("%p: [%s] underrun read:%u avail:%d max:%u",