ges: Check if GstDiscoverer could be created at init time
authorThibault Saunier <thibault.saunier@osg.samsung.com>
Tue, 15 Nov 2016 18:09:10 +0000 (15:09 -0300)
committerThibault Saunier <thibault.saunier@osg.samsung.com>
Tue, 15 Nov 2016 18:19:42 +0000 (15:19 -0300)
And fail initialization if it is not the case, we make the assumption
it worked all around the codebase so we should really concider it fatal.

ges/ges-uri-asset.c
ges/ges.c

index cc70ab1..e8de919 100644 (file)
@@ -182,6 +182,7 @@ _asset_proxied (GESAsset * self, const gchar * new_uri)
 static void
 ges_uri_clip_asset_class_init (GESUriClipAssetClass * klass)
 {
+  GError *err;
   GstClockTime timeout;
   const gchar *timeout_str;
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -216,8 +217,20 @@ ges_uri_clip_asset_class_init (GESUriClipAssetClass * klass)
   if (errno)
     timeout = 60 * GST_SECOND;
 
-  klass->discoverer = gst_discoverer_new (timeout, NULL);
+  klass->discoverer = gst_discoverer_new (timeout, &err);
+  if (!klass->discoverer) {
+    GST_ERROR ("Could not create discoverer: %s", err->message);
+    g_error_free (err);
+    return;
+  }
+
   klass->sync_discoverer = gst_discoverer_new (timeout, NULL);
+  if (!klass->sync_discoverer) {
+    GST_ERROR ("Could not create discoverer: %s", err->message);
+    g_error_free (err);
+    return;
+  }
+
   g_signal_connect (klass->discoverer, "discovered",
       G_CALLBACK (discoverer_discovered_cb), NULL);
 
index 6127b69..836ade3 100644 (file)
--- a/ges/ges.c
+++ b/ges/ges.c
@@ -60,11 +60,20 @@ static gboolean
 ges_init_post (GOptionContext * context, GOptionGroup * group, gpointer data,
     GError ** error)
 {
+  GESUriClipAssetClass *uriasset_klass = NULL;
+
   if (ges_initialized) {
     GST_DEBUG ("already initialized ges");
     return TRUE;
   }
 
+  uriasset_klass = g_type_class_ref (GES_TYPE_URI_CLIP_ASSET);
+  if (!uriasset_klass->discoverer)
+    goto failed;
+
+  if (!uriasset_klass->sync_discoverer)
+    goto failed;
+
   /* register clip classes with the system */
 
   GES_TYPE_TEST_CLIP;
@@ -94,10 +103,19 @@ ges_init_post (GOptionContext * context, GOptionGroup * group, gpointer data,
 
   /* TODO: user-defined types? */
   ges_initialized = TRUE;
+  g_type_class_unref (uriasset_klass);
 
   GST_DEBUG ("GStreamer Editing Services initialized");
 
   return TRUE;
+
+failed:
+  if (uriasset_klass)
+    g_type_class_unref (uriasset_klass);
+
+  GST_ERROR ("Could not initialize GES.");
+
+  return FALSE;
 }
 
 /**
@@ -112,9 +130,8 @@ gboolean
 ges_init (void)
 {
   ges_init_pre (NULL, NULL, NULL, NULL);
-  ges_init_post (NULL, NULL, NULL, NULL);
 
-  return TRUE;
+  return ges_init_post (NULL, NULL, NULL, NULL);
 }
 
 #ifndef GST_DISABLE_OPTION_PARSING