Commit 010272a7 authored by Aurélien Zanelli's avatar Aurélien Zanelli Committed by Nicolas Dufresne

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.
parent de799f4d
......@@ -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 */ = 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",
min = MAX (ctl.value, GST_V4L2_MIN_BUFFERS);
gst_query_add_allocation_pool (query, pool, size, min, max);
/* we also support various metadata */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment