From 5b371048df63e63e1c6d1e85b598e043f3878a1d Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Sun, 4 Dec 2022 12:51:45 +0100 Subject: [PATCH] stream: always try to recycle a buffer Also try to recycle a buffer if the current buffer_id is invalid. Ignore -EPIPE from the sender, just ask for more data. -EPIPE is when the sende runs out of buffers so in that case we need to recycle one as well. Fixes #2874 --- src/pipewire/stream.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/pipewire/stream.c b/src/pipewire/stream.c index c1ae0df23..a7c1da187 100644 --- a/src/pipewire/stream.c +++ b/src/pipewire/stream.c @@ -1002,6 +1002,7 @@ static int impl_node_process_input(void *object) if (io->status == SPA_STATUS_HAVE_DATA && (b = get_buffer(stream, io->buffer_id)) != NULL) { /* push new buffer */ + pw_log_trace_fp("%p: push %d %p", stream, b->id, io); if (queue_push(impl, &impl->dequeued, b) == 0) { copy_position(impl, impl->dequeued.incount); if (b->busy) @@ -1009,13 +1010,15 @@ static int impl_node_process_input(void *object) call_process(impl); } } - if (io->status != SPA_STATUS_NEED_DATA) { + if (io->status != SPA_STATUS_NEED_DATA || io->buffer_id == SPA_ID_INVALID) { /* pop buffer to recycle */ if ((b = queue_pop(impl, &impl->queued))) { pw_log_trace_fp("%p: recycle buffer %d", stream, b->id); - } else if (io->status == -EPIPE) - return io->status; - io->buffer_id = b ? b->id : SPA_ID_INVALID; + io->buffer_id = b->id; + } else { + pw_log_trace_fp("%p: no buffers to recycle", stream); + io->buffer_id = SPA_ID_INVALID; + } io->status = SPA_STATUS_NEED_DATA; } if (impl->driving && impl->using_trigger)