filter: avoid losing buffers in some cases

If the filter process doesn't dequeue/queue a buffer (as can be the
case in jack-tunnel-sink under xrun cases), pw-filter will set the
io to NEED_DATA with ID_INVALID.

This will then make the mixer in the next cycle not recycle any buffers
and it won't be able to produce any new ones either.
If the filter the dequeues/queues a buffer in the next process, it won't
dequeue a buffer for recycle because io is NEED_DATA/INVALID from the
previous cycle (io != HAVE_DATA -> continue).

This will the continue in an infinite loop producing "out of buffers"
forever.

Also check that we actually have a buffer to recycle, if we don't we can
try to dequeue one and place that in the io. This will then unlock the
loop, make the mixer recycle the buffer and produce a new one.

This is the same logic as is present in pw-stream for the same reason.

Fixes #5246
Maybe also #3547
This commit is contained in:
Wim Taymans 2026-04-28 14:55:13 +02:00
parent 08efbf2254
commit 72b9577d3c

View file

@ -1055,7 +1055,8 @@ static int impl_node_process(void *object)
if (p->direction == SPA_DIRECTION_INPUT) { if (p->direction == SPA_DIRECTION_INPUT) {
res |= SPA_STATUS_NEED_DATA; res |= SPA_STATUS_NEED_DATA;
if (SPA_UNLIKELY(io->status != SPA_STATUS_HAVE_DATA)) if (SPA_UNLIKELY(io->status != SPA_STATUS_HAVE_DATA &&
io->buffer_id != SPA_ID_INVALID))
continue; continue;
/* pop buffer to recycle */ /* pop buffer to recycle */