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
This commit is contained in:
Marcin Radomski 2022-05-10 20:29:04 +02:00 committed by Wim Taymans
parent 9240a7b6f3
commit aa33c2841c

View file

@ -1288,10 +1288,10 @@ static void stream_process(void *data)
stream->buffer, MAXLENGTH, stream->buffer, MAXLENGTH,
index % MAXLENGTH, index % MAXLENGTH,
p, avail); p, avail);
index += avail;
} }
pd.playing_for = size; pd.playing_for = size;
pd.read_inc = size; pd.read_inc = size;
index += size;
spa_ringbuffer_read_update(&stream->ring, index); spa_ringbuffer_read_update(&stream->ring, index);
} }
pw_log_debug("%p: [%s] underrun read:%u avail:%d max:%u", pw_log_debug("%p: [%s] underrun read:%u avail:%d max:%u",