pulse: handle wraparound near the end correctly

If offset is near MAXLENGTH, we can read past the end of the
buffer. Use the ringbuffer API to correctly wraparound.
This commit is contained in:
Wim Taymans 2026-04-30 14:14:59 +02:00
parent e5dda30b38
commit a585b117da

View file

@ -100,7 +100,8 @@ static void sample_play_stream_process(void *data)
if (b->requested) if (b->requested)
size = SPA_MIN(size, b->requested * p->stride); size = SPA_MIN(size, b->requested * p->stride);
memcpy(d, s->buffer + p->offset, size); spa_ringbuffer_read_data(NULL, s->buffer, MAXLENGTH,
p->offset % MAXLENGTH, d, size);
p->offset += size; p->offset += size;