summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2013-06-03 17:07:10 +0200
committerMichael Olbrich <m.olbrich@pengutronix.de>2013-09-13 16:29:48 +0200
commit341ce15129f38b70d88a2506a7230f7cc7643450 (patch)
tree29c9aa937004ff644eb431a932c440f5dbcfa9ba
parent8463049802bedc66d0454aec2879fc1b206bf606 (diff)
downloadgst-plugins-good-341ce15129f38b70d88a2506a7230f7cc7643450.tar.gz
gst-plugins-good-341ce15129f38b70d88a2506a7230f7cc7643450.tar.xz
v4l2: call VIDIOC_REQBUFS with count = 0 in pool_finalize
Without this the following sequence fails: - set_caps() - object_stop() (does nothing) - set_format() -> VIDIOC_S_FMT - set_config() -> VIDIOC_REQBUFS with count = N - set_caps() - object_stop() - pool_finalize() - set_format() -> VIDIOC_S_FMT => EBUSY Usually the pool is started after set_config(), in which case object_stop() will result in a pool_stop and therefore VIDIOC_REQBUFS with count = 0 but that is not guaranteed. Also calling VIDIOC_REQBUFS with count = 0 in pool_finalize() if necessary fixes this problem. Fixes https://bugzilla.gnome.org/show_bug.cgi?id=701543
-rw-r--r--sys/v4l2/gstv4l2bufferpool.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/sys/v4l2/gstv4l2bufferpool.c b/sys/v4l2/gstv4l2bufferpool.c
index 35be4ed67..cb6ece5e3 100644
--- a/sys/v4l2/gstv4l2bufferpool.c
+++ b/sys/v4l2/gstv4l2bufferpool.c
@@ -540,6 +540,23 @@ start_failed:
}
}
+static void
+gst_v4l2_buffer_pool_free_buffers (GstV4l2BufferPool * pool)
+{
+ if (pool->num_buffers > 0) {
+ struct v4l2_requestbuffers breq;
+ memset (&breq, 0, sizeof (struct v4l2_requestbuffers));
+ breq.type = pool->obj->type;
+ breq.count = 0;
+ breq.memory = V4L2_MEMORY_MMAP;
+ if (v4l2_ioctl (pool->video_fd, VIDIOC_REQBUFS, &breq) < 0) {
+ GST_ERROR_OBJECT (pool, "error releasing buffers: %s",
+ g_strerror (errno));
+ }
+ pool->num_buffers = 0;
+ }
+}
+
static gboolean
gst_v4l2_buffer_pool_stop (GstBufferPool * bpool)
{
@@ -584,18 +601,7 @@ gst_v4l2_buffer_pool_stop (GstBufferPool * bpool)
g_free (pool->buffers);
pool->buffers = NULL;
- if (pool->num_buffers > 0) {
- struct v4l2_requestbuffers breq;
- memset (&breq, 0, sizeof (struct v4l2_requestbuffers));
- breq.type = obj->type;
- breq.count = 0;
- breq.memory = V4L2_MEMORY_MMAP;
- if (v4l2_ioctl (pool->video_fd, VIDIOC_REQBUFS, &breq) < 0) {
- GST_ERROR_OBJECT (pool, "error releasing buffers: %s",
- g_strerror (errno));
- }
- pool->num_buffers = 0;
- }
+ gst_v4l2_buffer_pool_free_buffers (pool);
return ret;
@@ -1005,6 +1011,8 @@ gst_v4l2_buffer_pool_finalize (GObject * object)
{
GstV4l2BufferPool *pool = GST_V4L2_BUFFER_POOL (object);
+ gst_v4l2_buffer_pool_free_buffers (pool);
+
if (pool->video_fd >= 0)
v4l2_close (pool->video_fd);
if (pool->allocator)