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
This commit is contained in:
Aurélien Zanelli 2014-07-25 17:42:20 +02:00 committed by Nicolas Dufresne
parent de799f4d84
commit 010272a796

View file

@ -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 */