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 11:37:23 -0500 |
commit | a4b961e27503a257c49ba6d059cc70ce8e691bd6 (patch) | |
tree | 53e4204e12241fef0adb065ba45436f96136bc6c | |
parent | 133bad7feea0659f34e9975a9b6372e8159129c4 (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 a1aa64e8b..2b9f21ca4 100644 --- a/sys/v4l2/gstv4l2bufferpool.c +++ b/sys/v4l2/gstv4l2bufferpool.c @@ -577,7 +577,7 @@ streamon_failed: } } -static gboolean +static void gst_v4l2_buffer_pool_streamoff (GstV4l2BufferPool * pool) { GstV4l2Object *obj = pool->obj; @@ -589,25 +589,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 GstFlowReturn @@ -831,11 +826,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]) { @@ -866,11 +857,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 @@ -907,10 +893,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) { @@ -960,14 +943,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 |