decklinkvideosrc: fix mode autodetection
authorJosep Torra <n770galaxy@gmail.com>
Wed, 22 Apr 2015 15:08:09 +0000 (17:08 +0200)
committerJosep Torra <n770galaxy@gmail.com>
Wed, 22 Apr 2015 15:20:22 +0000 (17:20 +0200)
The autodetection mode was broken because a race condition in the input mode
setting. The mode could be reverted back when it was replaced in
the streaming thread by the old mode in the middle of mode changed callback.

sys/decklink/gstdecklinkvideosrc.cpp

index 0432e8c..4e8bcee 100644 (file)
@@ -265,9 +265,13 @@ gst_decklink_video_src_set_caps (GstBaseSrc * bsrc, GstCaps * caps)
     GST_DEBUG_OBJECT (self, "Pad already has caps %" GST_PTR_FORMAT, caps);
 
     if (!gst_caps_is_equal (caps, current_caps)) {
-      GST_ERROR_OBJECT (self, "New caps are not equal to old caps");
+      GST_DEBUG_OBJECT (self, "New caps, reconfiguring");
       gst_caps_unref (current_caps);
-      return FALSE;
+      if (self->mode == GST_DECKLINK_MODE_AUTO) {
+        return TRUE;
+      } else {
+        return FALSE;
+      }
     } else {
       gst_caps_unref (current_caps);
       return TRUE;
@@ -514,9 +518,6 @@ gst_decklink_video_src_create (GstPushSrc * bsrc, GstBuffer ** buffer)
         f->mode);
     self->caps_mode = f->mode;
     g_mutex_unlock (&self->lock);
-    g_mutex_lock (&self->input->lock);
-    self->input->mode = gst_decklink_get_mode (f->mode);
-    g_mutex_unlock (&self->input->lock);
     caps = gst_decklink_mode_get_caps (f->mode);
     gst_video_info_from_caps (&self->info, caps);
     gst_base_src_set_caps (GST_BASE_SRC_CAST (bsrc), caps);