autodetect: demote candidate error to warning and plug fake{sink,src}
authorStefan Sauer <ensonic@users.sf.net>
Sat, 22 Feb 2014 19:19:49 +0000 (20:19 +0100)
committerStefan Sauer <ensonic@users.sf.net>
Sun, 23 Feb 2014 19:34:43 +0000 (20:34 +0100)
In the case where we have no suitable candidate we post a warning and plug a
fake-element. Do the same when non of the candidate work.

This is more consistent and plugin the fakesink as a fallback is probably
helpful for running unit tests without requiring hardware src/sink elements.

Fixes #722981

gst/autodetect/gstautodetect.c

index a3a1c8a..6970eaa 100644 (file)
@@ -313,20 +313,27 @@ gst_auto_detect_find_best (GstAutoDetect * self)
 
   GST_DEBUG_OBJECT (self, "done trying");
   if (!choice) {
+    /* We post a warning and plug a fake-element. This is convenient for running
+     * tests without requiring hardware src/sinks. */
     if (errors) {
-      /* FIXME: we forward the first error for now; but later on it might make
-       * sense to actually analyse them */
-      message = gst_message_ref (GST_MESSAGE (errors->data));
-      GST_DEBUG_OBJECT (self, "reposting message %p", message);
-      gst_element_post_message (GST_ELEMENT_CAST (self), message);
+      GError *err = NULL;
+      gchar *dbg = NULL;
+
+      /* FIXME: we forward the first message for now; but later on it might make
+       * sense to forward all so that apps can actually analyse them. */
+      gst_message_parse_error (GST_MESSAGE (errors->data), &err, &dbg);
+      gst_element_post_message (GST_ELEMENT_CAST (self),
+          gst_message_new_warning (GST_OBJECT_CAST (self), err, dbg));
+      g_error_free (err);
+      g_free (dbg);
     } else {
       /* send warning message to application and use a fakesrc */
       GST_ELEMENT_WARNING (self, RESOURCE, NOT_FOUND, (NULL),
           ("Failed to find a usable %s %s", self->media_klass_lc,
               self->type_klass_lc));
-      choice = gst_auto_detect_create_fake_element (self);
-      gst_element_set_state (choice, GST_STATE_READY);
     }
+    choice = gst_auto_detect_create_fake_element (self);
+    gst_element_set_state (choice, GST_STATE_READY);
   }
   gst_object_unref (bus);
   gst_plugin_feature_list_free (list);