summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorNicolas Dufresne <nicolas.dufresne@collabora.com>2016-06-07 12:41:19 -0400
committerNicolas Dufresne <nicolas.dufresne@collabora.com>2016-06-07 12:46:53 -0400
commitec169a1517317f696b1d764ed568dd6f67a6c128 (patch)
treee532b2f7abedf8fdfd52197a6bd016e45804641f /sys
parent30d2918ab0afc1835656cbcd5b6e15855740f198 (diff)
v4l2src: Avoid decide allocation on active pool
v4l2src will renegotiate only if the format have changed. As of now, it's not possible to change the allocationw without resetting the camera. To avoid unwanted side effect, simply keep the old allocation if no renegotiation is taking place. This fixes assertion and possible failures in USERPTR or DMABUF import mode (when using downstream pools). https://bugzilla.gnome.org/show_bug.cgi?id=754042
Diffstat (limited to 'sys')
-rw-r--r--sys/v4l2/gstv4l2src.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/sys/v4l2/gstv4l2src.c b/sys/v4l2/gstv4l2src.c
index 235eda471..348ab7fbb 100644
--- a/sys/v4l2/gstv4l2src.c
+++ b/sys/v4l2/gstv4l2src.c
@@ -489,6 +489,34 @@ gst_v4l2src_decide_allocation (GstBaseSrc * bsrc, GstQuery * query)
ret = gst_v4l2src_set_format (src, caps);
gst_caps_unref (caps);
src->pending_set_fmt = FALSE;
+ } else if (gst_buffer_pool_is_active (src->v4l2object->pool)) {
+ /* Trick basesrc into not deactivating the active pool. Renegotiating here
+ * would otherwise turn off and on the camera. */
+ GstAllocator *allocator;
+ GstAllocationParams params;
+ GstBufferPool *pool;
+
+ gst_base_src_get_allocator (bsrc, &allocator, &params);
+ pool = gst_base_src_get_buffer_pool (bsrc);
+
+ if (gst_query_get_n_allocation_params (query))
+ gst_query_set_nth_allocation_param (query, 0, allocator, &params);
+ else
+ gst_query_add_allocation_param (query, allocator, &params);
+
+ if (gst_query_get_n_allocation_pools (query))
+ gst_query_set_nth_allocation_pool (query, 0, pool,
+ src->v4l2object->info.size, 1, 0);
+ else
+ gst_query_add_allocation_pool (query, pool, src->v4l2object->info.size, 1,
+ 0);
+
+ if (pool)
+ gst_object_unref (pool);
+ if (allocator)
+ gst_object_unref (allocator);
+
+ return GST_BASE_SRC_CLASS (parent_class)->decide_allocation (bsrc, query);
}
if (ret) {