capture_on_process() leaks the PipeWire buffer on the p == NULL and
underrun early-return paths by not calling pw_stream_queue_buffer().
The stream eventually starves from its buffer pool.

Reported-by: Pavee Hui <[email protected]>
Fixes: c2d3d1c29415 ("audio/pwaudio.c: Add Pipewire audio backend for QEMU")
Signed-off-by: Marc-André Lureau <[email protected]>
---
 audio/pwaudio.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/audio/pwaudio.c b/audio/pwaudio.c
index a59c22e60b87..af360e2ec5ed 100644
--- a/audio/pwaudio.c
+++ b/audio/pwaudio.c
@@ -171,6 +171,7 @@ capture_on_process(void *data)
     buf = b->buffer;
     p = buf->datas[0].data;
     if (p == NULL) {
+        pw_stream_queue_buffer(v->stream, b);
         return;
     }
     offs = SPA_MIN(buf->datas[0].chunk->offset, buf->datas[0].maxsize);
@@ -181,6 +182,8 @@ capture_on_process(void *data)
 
     if (filled < 0) {
         error_report("%p: underrun write:%u filled:%d", p, index, filled);
+        pw_stream_queue_buffer(v->stream, b);
+        return;
     } else {
         if ((uint32_t) filled + n_bytes > RINGBUFFER_SIZE) {
             error_report("%p: overrun write:%u filled:%d + size:%u > max:%u",

-- 
2.56.0.rc0.29.g47ce80527c56


Reply via email to