From a585b117dad4ebb0b4b95cb531b411ae26eb146d Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 30 Apr 2026 14:14:59 +0200 Subject: [PATCH] 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. --- src/modules/module-protocol-pulse/sample-play.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/module-protocol-pulse/sample-play.c b/src/modules/module-protocol-pulse/sample-play.c index 09b0e75cc..719604654 100644 --- a/src/modules/module-protocol-pulse/sample-play.c +++ b/src/modules/module-protocol-pulse/sample-play.c @@ -100,7 +100,8 @@ static void sample_play_stream_process(void *data) if (b->requested) 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;