From: Aurélien Zanelli Date: Tue, 7 Oct 2014 13:29:33 +0000 (+0200) Subject: v4l2bufferpool: cleanly handle streamon failure for output device X-Git-Tag: 1.19.3~509^2~4090 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1dcc8832616bb382e39355236dc6c312083a88e4;p=platform%2Fupstream%2Fgstreamer.git v4l2bufferpool: cleanly handle streamon failure for output device On streamon failure, the queued buffer is not released from the bufferpool class point of view because it is queued to the driver and the flush logic is not performed since we are not in streaming state. It causes the v4l2 bufferpool to always return that stop method failed and to leak v4l2 objects and buffers. This commit solve this by performing the flush logic in error case, ie flushing the allocator and restoring queued buffer state to non-queued. https://bugzilla.gnome.org/show_bug.cgi?id=738102 --- diff --git a/sys/v4l2/gstv4l2bufferpool.c b/sys/v4l2/gstv4l2bufferpool.c index dba69e7..477cbc6 100644 --- a/sys/v4l2/gstv4l2bufferpool.c +++ b/sys/v4l2/gstv4l2bufferpool.c @@ -1712,7 +1712,21 @@ gst_v4l2_buffer_pool_process (GstV4l2BufferPool * pool, GstBuffer ** buf) /* if we are not streaming yet (this is the first buffer, start * streaming now */ if (!gst_v4l2_buffer_pool_streamon (pool)) { + /* don't check return value because qbuf would have failed */ + gst_v4l2_is_buffer_valid (to_queue, &group); + + /* qbuf has taken the ref of the to_queue buffer but we are no in + * streaming state, so the flush logic won't be performed. + * To avoid leaks, flush the allocator and restore the queued + * buffer as non-queued */ + gst_v4l2_allocator_flush (pool->vallocator); + + pool->buffers[group->buffer.index] = NULL; + + gst_mini_object_set_qdata (GST_MINI_OBJECT (to_queue), + GST_V4L2_IMPORT_QUARK, NULL, NULL); gst_buffer_unref (to_queue); + g_atomic_int_add (&pool->num_queued, -1); goto start_failed; }