ges-launch: Remember URIS that we tried to discover

So we do not fail several time trying to discover the same URI

Conflicts:
	tools/ges-launch.c
This commit is contained in:
Thibault Saunier 2013-10-11 17:05:03 -03:00
parent 35acbae033
commit 87ca058e3f

View file

@ -37,6 +37,7 @@ static GESPipeline *pipeline = NULL;
static gboolean seenerrors = FALSE; static gboolean seenerrors = FALSE;
static gchar **new_paths = NULL; static gchar **new_paths = NULL;
static GMainLoop *mainloop; static GMainLoop *mainloop;
static GHashTable *tried_uris;
static gchar * static gchar *
ensure_uri (gchar * location) ensure_uri (gchar * location)
@ -73,14 +74,18 @@ source_moved_cb (GESProject * project, GError * error, GESAsset * asset)
for (i = 0; new_paths[i] != NULL; i++) { for (i = 0; new_paths[i] != NULL; i++) {
gchar *basename, *res; gchar *basename, *res;
if (g_str_has_prefix (old_uri, new_paths[i]))
continue;
basename = g_path_get_basename (old_uri); basename = g_path_get_basename (old_uri);
res = g_build_filename (new_paths[i], basename, NULL); res = g_build_filename (new_paths[i], basename, NULL);
g_free (basename); g_free (basename);
return res; if (g_hash_table_lookup (tried_uris, res)) {
GST_DEBUG ("File already tried: %s\n", res);
g_free (res);
} else {
g_hash_table_add (tried_uris, g_strdup (res));
return res;
}
} }
return NULL; return NULL;
@ -90,7 +95,7 @@ static void
error_loading_asset_cb (GESProject * project, GError * error, error_loading_asset_cb (GESProject * project, GError * error,
const gchar * failed_id, GType extractable_type) const gchar * failed_id, GType extractable_type)
{ {
g_printerr ("Error loading asset %s: %s", failed_id, error->message); g_printerr ("Error loading asset %s: %s\n", failed_id, error->message);
g_main_loop_quit (mainloop); g_main_loop_quit (mainloop);
} }
@ -624,6 +629,7 @@ main (int argc, gchar ** argv)
exit (0); exit (0);
} }
tried_uris = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
if (((!load_path && (argc < 4)))) { if (((!load_path && (argc < 4)))) {
g_printf ("%s", g_option_context_get_help (ctx, TRUE, NULL)); g_printf ("%s", g_option_context_get_help (ctx, TRUE, NULL));
g_option_context_free (ctx); g_option_context_free (ctx);
@ -704,5 +710,6 @@ main (int argc, gchar ** argv)
gst_object_unref (pipeline); gst_object_unref (pipeline);
g_hash_table_unref (tried_uris);
return (int) seenerrors; return (int) seenerrors;
} }