mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
pulse-server: keep read index in sync
Keep the ringbuffer and read_index variable in sync or else we might ask for more data than maxlength and cause an overflow. Fixes #2799
This commit is contained in:
parent
51e8ff7d8e
commit
f801dc0886
1 changed files with 4 additions and 3 deletions
|
|
@ -1428,15 +1428,16 @@ static void stream_process(void *data)
|
||||||
}
|
}
|
||||||
if ((stream->attr.prebuf == 0 || do_flush) && !stream->corked) {
|
if ((stream->attr.prebuf == 0 || do_flush) && !stream->corked) {
|
||||||
if (avail > 0) {
|
if (avail > 0) {
|
||||||
|
avail = SPA_MIN((uint32_t)avail, size);
|
||||||
spa_ringbuffer_read_data(&stream->ring,
|
spa_ringbuffer_read_data(&stream->ring,
|
||||||
stream->buffer, MAXLENGTH,
|
stream->buffer, MAXLENGTH,
|
||||||
index % MAXLENGTH,
|
index % MAXLENGTH,
|
||||||
p, SPA_MIN((uint32_t)avail, size));
|
p, avail);
|
||||||
index += avail;
|
index += avail;
|
||||||
|
pd.read_inc = avail;
|
||||||
|
spa_ringbuffer_read_update(&stream->ring, index);
|
||||||
}
|
}
|
||||||
pd.playing_for = size;
|
pd.playing_for = size;
|
||||||
pd.read_inc = size;
|
|
||||||
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",
|
||||||
stream, client->name, index, avail, minreq);
|
stream, client->name, index, avail, minreq);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue