From 38b68cbbd7a90fc3b77db301cda99e96aecc808d Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Thu, 12 Jul 2018 15:11:39 -0400 Subject: [PATCH] v4l2bufferpool: Remove duplicate check We were calling gst_v4l2_is_buffer_valid() before and inside gst_v4l2_buffer_pool_qbuf() as we needed to access the group. The second check failed since the writability of the buffer get inherited from the GstMemory, which lead to pipeline failure. As we cannot avoid the extra ref, it would be racy otherwise, just pass the group to _dbuf() so it does not have to call gst_v4l2_is_buffer_valid() again. https://bugzilla.gnome.org/show_bug.cgi?id=796692 --- sys/v4l2/gstv4l2bufferpool.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/sys/v4l2/gstv4l2bufferpool.c b/sys/v4l2/gstv4l2bufferpool.c index a57229368c..aecdfdf679 100644 --- a/sys/v4l2/gstv4l2bufferpool.c +++ b/sys/v4l2/gstv4l2bufferpool.c @@ -1057,18 +1057,13 @@ no_buffers: } static GstFlowReturn -gst_v4l2_buffer_pool_qbuf (GstV4l2BufferPool * pool, GstBuffer * buf) +gst_v4l2_buffer_pool_qbuf (GstV4l2BufferPool * pool, GstBuffer * buf, + GstV4l2MemoryGroup * group) { - GstV4l2MemoryGroup *group = NULL; const GstV4l2Object *obj = pool->obj; GstClockTime timestamp; gint index; - if (!gst_v4l2_is_buffer_valid (buf, &group)) { - GST_ERROR_OBJECT (pool, "invalid buffer %p", buf); - return GST_FLOW_ERROR; - } - index = group->buffer.index; if (pool->buffers[index] != NULL) @@ -1415,7 +1410,7 @@ gst_v4l2_buffer_pool_release_buffer (GstBufferPool * bpool, GstBuffer * buffer) /* queue back in the device */ if (pool->other_pool) gst_v4l2_buffer_pool_prepare_buffer (pool, buffer, NULL); - if (gst_v4l2_buffer_pool_qbuf (pool, buffer) != GST_FLOW_OK) + if (gst_v4l2_buffer_pool_qbuf (pool, buffer, group) != GST_FLOW_OK) pclass->release_buffer (bpool, buffer); } else { /* Simply release invalide/modified buffer, the allocator will @@ -1915,9 +1910,13 @@ gst_v4l2_buffer_pool_process (GstV4l2BufferPool * pool, GstBuffer ** buf) gst_buffer_unref (to_queue); goto prepare_failed; } + + /* retreive the group */ + gst_v4l2_is_buffer_valid (to_queue, &group); } - if ((ret = gst_v4l2_buffer_pool_qbuf (pool, to_queue)) != GST_FLOW_OK) + if ((ret = gst_v4l2_buffer_pool_qbuf (pool, to_queue, group)) + != GST_FLOW_OK) goto queue_failed; /* if we are not streaming yet (this is the first buffer, start