decklink: Fix support for HW without output
authorNicolas Dufresne <nicolas.dufresne@collabora.com>
Sat, 29 Mar 2014 22:34:26 +0000 (18:34 -0400)
committerNicolas Dufresne <nicolas.dufresne@collabora.com>
Wed, 23 Apr 2014 16:42:44 +0000 (12:42 -0400)
Devices suitable for decklinksrc may not have any output, hence querying
the input returns NULL. Add support for all cases where
input/output/config may be missing.

https://bugzilla.gnome.org/show_bug.cgi?id=727306

sys/decklink/gstdecklink.cpp
sys/decklink/gstdecklinksink.cpp
sys/decklink/gstdecklinksrc.cpp

index 067665e..8a186f2 100644 (file)
@@ -244,6 +244,11 @@ init_devices (void)
 
     ret = iterator->Next (&decklink);
     i++;
+
+    if (i == 10) {
+      GST_WARNING ("this hardware has more then 10 devices");
+      break;
+    }
   }
 
   n_devices = i;
index 7f0ec61..425a757 100644 (file)
@@ -321,6 +321,7 @@ gst_decklink_sink_finalize (GObject * object)
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
+/* FIXME: post error messages for the misc. failures */
 static gboolean
 gst_decklink_sink_start (GstDecklinkSink * decklinksink)
 {
@@ -335,6 +336,10 @@ gst_decklink_sink_start (GstDecklinkSink * decklinksink)
   }
 
   decklinksink->output = gst_decklink_get_nth_output (decklinksink->device_number);
+  if (!decklinksink->decklink) {
+    GST_WARNING ("no output for device %d", decklinksink->device_number);
+    return FALSE;
+  }
 
   decklinksink->output->SetAudioCallback (decklinksink->callback);
 
index 7c2683a..1dc554d 100644 (file)
@@ -424,6 +424,10 @@ gst_decklink_src_start (GstElement * element)
   }
 
   decklinksrc->input = gst_decklink_get_nth_input (decklinksrc->device_number);
+  if (decklinksrc->input == NULL) {
+    GST_ERROR ("no input source for device %i", decklinksrc->device_number);
+    return FALSE;
+  }
 
   delegate = new DeckLinkCaptureDelegate ();
   delegate->priv = decklinksrc;
@@ -435,6 +439,10 @@ gst_decklink_src_start (GstElement * element)
 
   decklinksrc->config = gst_decklink_get_nth_config (decklinksrc->device_number);
   config = decklinksrc->config;
+  if (decklinksrc->config == NULL) {
+    GST_ERROR ("no config for device %i", decklinksrc->device_number);
+    return FALSE;
+  }
 
   switch (decklinksrc->connection) {
     default: