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.
This commit is contained in:
Ashok Sidipotu 2024-02-21 13:45:52 +05:30
parent 70d2b0eeb4
commit 46c4776dc2

View file

@ -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;