[gst-cvs] gst-plugins-good: v4l2src: do not try to change device format if it' s already correct

Sebastian Dröge slomo at kemper.freedesktop.org
Wed Jun 16 08:48:51 PDT 2010


Module: gst-plugins-good
Branch: master
Commit: f06b105058e73162275b50bdba89c6791e218d03
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=f06b105058e73162275b50bdba89c6791e218d03

Author: Havoc Pennington <hp at pobox.com>
Date:   Wed Jun 16 11:21:35 2010 -0400

v4l2src: do not try to change device format if it's already correct

This allows set_caps to succeed if caps change in a way that
would not modify the format we're getting from the hardware.
Otherwise if not in NULL state, setting caps would fail
with EBUSY.

With this change, in some cases it's OK to go PLAYING->READY->PLAYING
rather than PLAYING->NULL->PLAYING to avoid a time-consuming close
and reopen of the device.

Fixes #621723

---

 sys/v4l2/gstv4l2object.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/sys/v4l2/gstv4l2object.c b/sys/v4l2/gstv4l2object.c
index 46a5c6e..2531d2e 100644
--- a/sys/v4l2/gstv4l2object.c
+++ b/sys/v4l2/gstv4l2object.c
@@ -1869,6 +1869,22 @@ gst_v4l2_object_set_format (GstV4l2Object * v4l2object, guint32 pixelformat,
   if (v4l2_ioctl (fd, VIDIOC_G_FMT, &format) < 0)
     goto get_fmt_failed;
 
+  if (format.type == v4l2object->type &&
+      format.fmt.pix.width == width &&
+      format.fmt.pix.height == height &&
+      format.fmt.pix.pixelformat == pixelformat) {
+    /* Nothing to do. We want to succeed immediately
+     * here because setting the same format back
+     * can still fail due to EBUSY. By short-circuiting
+     * here, we allow pausing and re-playing pipelines
+     * with changed caps, as long as the changed caps
+     * do not change the webcam's format. Otherwise,
+     * any caps change would require us to go to NULL
+     * state to close the device and set format.
+     */
+    return TRUE;
+  }
+
   format.type = v4l2object->type;
   format.fmt.pix.width = width;
   format.fmt.pix.height = height;





More information about the Gstreamer-commits mailing list