From fe3a70fefde604ce17bdd10175c894066de9881f Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Mon, 9 Jul 2018 15:33:02 -0400 Subject: [PATCH] v4l2src: Simplify format handling Always initially use try_format(), delaying set_format() to when the allocation is being negotiated. This avoid having two code paths, and will be help adding support for properly importing buffers of specific strides and offsets. https://bugzilla.gnome.org/show_bug.cgi?id=583890 --- sys/v4l2/gstv4l2src.c | 45 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/sys/v4l2/gstv4l2src.c b/sys/v4l2/gstv4l2src.c index 88c813f..a87bcdc 100644 --- a/sys/v4l2/gstv4l2src.c +++ b/sys/v4l2/gstv4l2src.c @@ -446,33 +446,28 @@ gst_v4l2src_fixate (GstBaseSrc * basesrc, GstCaps * caps, GstStructure * pref_s) fcaps = gst_caps_copy_nth (caps, i); - if (GST_V4L2_IS_ACTIVE (obj)) { - /* try hard to avoid TRY_FMT since some UVC camera just crash when this - * is called at run-time. */ - if (gst_v4l2_object_caps_is_subset (obj, fcaps)) { - gst_caps_unref (fcaps); - fcaps = gst_v4l2_object_get_current_caps (obj); - break; - } + /* try hard to avoid TRY_FMT since some UVC camera just crash when this + * is called at run-time. */ + if (gst_v4l2_object_caps_is_subset (obj, fcaps)) { + gst_caps_unref (fcaps); + fcaps = gst_v4l2_object_get_current_caps (obj); + break; + } - /* Just check if the format is acceptable, once we know - * no buffers should be outstanding we try S_FMT. - * - * Basesrc will do an allocation query that - * should indirectly reclaim buffers, after that we can - * set the format and then configure our pool */ - if (gst_v4l2_object_try_format (obj, fcaps, &error)) { - /* make sure the caps changed before doing anything */ - if (gst_v4l2_object_caps_equal (obj, fcaps)) - break; - - v4l2src->renegotiation_adjust = v4l2src->offset + 1; - v4l2src->pending_set_fmt = TRUE; - break; - } - } else { - if (gst_v4l2src_set_format (v4l2src, fcaps, &error)) + /* Just check if the format is acceptable, once we know + * no buffers should be outstanding we try S_FMT. + * + * Basesrc will do an allocation query that + * should indirectly reclaim buffers, after that we can + * set the format and then configure our pool */ + if (gst_v4l2_object_try_format (obj, fcaps, &error)) { + /* make sure the caps changed before doing anything */ + if (gst_v4l2_object_caps_equal (obj, fcaps)) break; + + v4l2src->renegotiation_adjust = v4l2src->offset + 1; + v4l2src->pending_set_fmt = TRUE; + break; } /* Only EIVAL make sense, report any other errors, this way we don't keep -- 2.7.4