diff options
author | Nicolas Dufresne <nicolas.dufresne@collabora.co.uk> | 2015-01-08 11:37:23 -0500 |
---|---|---|
committer | Nicolas Dufresne <nicolas.dufresne@collabora.co.uk> | 2015-01-08 23:58:04 -0500 |
commit | efc5332f1e9b456d7a0032bee4dbd104235582f5 (patch) | |
tree | 91fb3a3be380dd6b1ead37e21074669e784c715f | |
parent | 50f05a401e03aa3aa8293be2a273e38f1fb3fd66 (diff) |
v4l2bufferpool: Never fail on streamoff
Failing streamoff prevents allocator from being disposed hence
lead to device FD leak. There is no known cases where streamoff
may fails for which we'd still be streaming. streamoff is known
to fail when a device is being unplugged (in which case errno
19/ENODEV is set).
https://bugzilla.gnome.org/show_bug.cgi?id=732734
-rw-r--r-- | sys/v4l2/gstv4l2bufferpool.c | 41 |
1 files changed, 8 insertions, 33 deletions
diff --git a/sys/v4l2/gstv4l2bufferpool.c b/sys/v4l2/gstv4l2bufferpool.c index b8d7bb141..b5b8b1323 100644 --- a/sys/v4l2/gstv4l2bufferpool.c +++ b/sys/v4l2/gstv4l2bufferpool.c @@ -568,7 +568,7 @@ streamon_failed: } } -static gboolean +static void gst_v4l2_buffer_pool_streamoff (GstV4l2BufferPool * pool) { GstV4l2Object *obj = pool->obj; @@ -580,25 +580,20 @@ gst_v4l2_buffer_pool_streamoff (GstV4l2BufferPool * pool) case GST_V4L2_IO_DMABUF_IMPORT: if (pool->streaming) { if (v4l2_ioctl (pool->video_fd, VIDIOC_STREAMOFF, &obj->type) < 0) - goto streamoff_failed; + GST_WARNING_OBJECT (pool, "STREAMOFF failed with errno %d (%s)", + errno, g_strerror (errno)); pool->streaming = FALSE; GST_DEBUG_OBJECT (pool, "Stopped streaming"); + + if (pool->vallocator) + gst_v4l2_allocator_flush (pool->vallocator); } break; default: break; } - - return TRUE; - -streamoff_failed: - { - GST_ERROR_OBJECT (pool, "error with STREAMOFF %d (%s)", errno, - g_strerror (errno)); - return FALSE; - } } static void @@ -827,11 +822,7 @@ gst_v4l2_buffer_pool_stop (GstBufferPool * bpool) pool->other_pool = NULL; } - if (!gst_v4l2_buffer_pool_streamoff (pool)) - goto streamoff_failed; - - if (pool->vallocator) - gst_v4l2_allocator_flush (pool->vallocator); + gst_v4l2_buffer_pool_streamoff (pool); for (i = 0; i < VIDEO_MAX_FRAME; i++) { if (pool->buffers[i]) { @@ -862,11 +853,6 @@ gst_v4l2_buffer_pool_stop (GstBufferPool * bpool) } return ret; - - /* ERRORS */ -streamoff_failed: - GST_ERROR_OBJECT (pool, "device refused to stop streaming"); - return FALSE; } static void @@ -903,10 +889,7 @@ gst_v4l2_buffer_pool_flush_stop (GstBufferPool * bpool) if (pool->other_pool) gst_buffer_pool_set_flushing (pool->other_pool, FALSE); - if (!gst_v4l2_buffer_pool_streamoff (pool)) - goto stop_failed; - - gst_v4l2_allocator_flush (pool->vallocator); + gst_v4l2_buffer_pool_streamoff (pool); /* Reset our state */ switch (obj->mode) { @@ -956,14 +939,6 @@ streamon: gst_v4l2_buffer_pool_streamon (pool); gst_poll_set_flushing (pool->poll, FALSE); - - return; - - /* ERRORS */ -stop_failed: - { - GST_ERROR_OBJECT (pool, "device refused to flush"); - } } static GstFlowReturn |