From 46c4776dc27f7f17b1a7544f9b8218fce6e1128e Mon Sep 17 00:00:00 2001 From: Ashok Sidipotu Date: Wed, 21 Feb 2024 13:45:52 +0530 Subject: [PATCH] gst: add retry mechanism when producer gets a busy buffer Producer streams get busy buffers when slow consumers hold on to buffers and not release them on time. Add a retry mechanism as there can be non busy buffers available and producer can go on generating the output. --- src/gst/gstpipewirepool.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/gst/gstpipewirepool.c b/src/gst/gstpipewirepool.c index 676a2d054..e7a38ac88 100644 --- a/src/gst/gstpipewirepool.c +++ b/src/gst/gstpipewirepool.c @@ -161,6 +161,7 @@ acquire_buffer (GstBufferPool * pool, GstBuffer ** buffer, GstPipeWirePool *p = GST_PIPEWIRE_POOL (pool); GstPipeWirePoolData *data; struct pw_buffer *b; + guint retry = 0; GST_OBJECT_LOCK (pool); while (TRUE) { @@ -169,6 +170,16 @@ acquire_buffer (GstBufferPool * pool, GstBuffer ** buffer, if ((b = pw_stream_dequeue_buffer(p->stream))) break; + else if (errno == EBUSY) { + if (!retry) { + struct pw_time time; + pw_stream_get_time_n (p->stream, &time, sizeof(time)); + retry = time.avail_buffers + time.queued_buffers + 1; + } + + if(--retry) + continue; + } if (params && (params->flags & GST_BUFFER_POOL_ACQUIRE_FLAG_DONTWAIT)) goto no_more_buffers;