validate: factor out create_config()
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Mon, 11 May 2015 09:08:36 +0000 (11:08 +0200)
committerThibault Saunier <tsaunier@gnome.org>
Mon, 11 May 2015 19:55:24 +0000 (21:55 +0200)
Reviewers: thiblahute

Differential Revision: http://phabricator.freedesktop.org/D157

validate/gst/validate/validate.c

index 3dfbf16cc6425cf11b8e79247cd859617e9f2aa4..c3d980d1c7ed77c72278e9c0fc8357b89aab748a 100644 (file)
@@ -88,23 +88,38 @@ _free_plugin_config (gpointer data)
   g_list_free_full (data, (GDestroyNotify) gst_structure_free);
 }
 
+static GList *
+create_config (const gchar * path, const gchar * suffix)
+{
+  GList *structures = NULL, *tmp, *result = NULL;
+
+  if (!suffix)
+    return NULL;
+
+  structures = gst_validate_utils_structs_parse_from_filename (path);
+
+  for (tmp = structures; tmp; tmp = tmp->next) {
+    if (gst_structure_has_name (tmp->data, suffix))
+      result = g_list_append (result, tmp->data);
+  }
+
+  return result;
+}
+
 GList *
 gst_validate_plugin_get_config (GstPlugin * plugin)
 {
-  GList *structures = NULL, *tmp, *plugin_conf = NULL;
-  const gchar *config = g_getenv ("GST_VALIDATE_CONFIG");
+  GList *plugin_conf;
+  const gchar *suffix;
 
   if ((plugin_conf =
           g_object_get_data (G_OBJECT (plugin), GST_VALIDATE_PLUGIN_CONFIG)))
     return plugin_conf;
 
-  if (config)
-    structures = gst_validate_utils_structs_parse_from_filename (config);
+  suffix = gst_plugin_get_name (plugin);
+
+  plugin_conf = create_config (g_getenv ("GST_VALIDATE_CONFIG"), suffix);
 
-  for (tmp = structures; tmp; tmp = tmp->next) {
-    if (gst_structure_has_name (tmp->data, gst_plugin_get_name (plugin)))
-      plugin_conf = g_list_append (plugin_conf, tmp->data);
-  }
   g_object_set_data_full (G_OBJECT (plugin), GST_VALIDATE_PLUGIN_CONFIG,
       plugin_conf, _free_plugin_config);