diff options
author | Aurélien Zanelli <aurelien.zanelli@parrot.com> | 2014-07-25 17:42:20 +0200 |
---|---|---|
committer | Nicolas Dufresne <nicolas.dufresne@collabora.co.uk> | 2014-07-25 13:43:09 -0400 |
commit | 010272a796325d3b9a94b5dcf887706cd2524b27 (patch) | |
tree | b4dd3d0f3e108cef9840378f63ad9b25d088404c | |
parent | de799f4d8435d579f8c8ecc1aec6852589a5a6d4 (diff) |
v4l2object: query minimum required buffers for output
Some v4l2 devices could require a minimum buffers different from default
values. Rather than blindly propose a pool with min-buffers set to the
default value, it ask the device using control ioctl.
https://bugzilla.gnome.org/show_bug.cgi?id=733750
-rw-r--r-- | sys/v4l2/gstv4l2object.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/sys/v4l2/gstv4l2object.c b/sys/v4l2/gstv4l2object.c index 583c3d4b6..f8a6c4dc2 100644 --- a/sys/v4l2/gstv4l2object.c +++ b/sys/v4l2/gstv4l2object.c @@ -3412,6 +3412,7 @@ gst_v4l2_object_propose_allocation (GstV4l2Object * obj, GstQuery * query) guint size, min, max; GstCaps *caps; gboolean need_pool; + struct v4l2_control ctl = { 0, }; /* Set defaults allocation parameters */ size = obj->info.size; @@ -3444,6 +3445,15 @@ gst_v4l2_object_propose_allocation (GstV4l2Object * obj, GstQuery * query) gst_structure_free (config); } + /* Some devices may expose a minimum */ + ctl.id = V4L2_CID_MIN_BUFFERS_FOR_OUTPUT; + if (v4l2_ioctl (obj->video_fd, VIDIOC_G_CTRL, &ctl) >= 0) { + GST_DEBUG_OBJECT (obj->element, "driver require a miminum of %d buffers", + ctl.value); + + min = MAX (ctl.value, GST_V4L2_MIN_BUFFERS); + } + gst_query_add_allocation_pool (query, pool, size, min, max); /* we also support various metadata */ |