ges: Check if GstDiscoverer could be created at init time

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.
This commit is contained in:
Thibault Saunier 2016-11-15 15:09:10 -03:00
parent acfa0e9045
commit 9bc06c755a
2 changed files with 33 additions and 3 deletions

View 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);

View file

@ -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