registry: Add plugins to the registry we are loading and not default one
authorThibault Saunier <tsaunier@gnome.org>
Tue, 21 Jul 2015 11:35:33 +0000 (13:35 +0200)
committerNicolas Dufresne <nicolas.dufresne@collabora.com>
Wed, 5 Aug 2015 21:32:00 +0000 (17:32 -0400)
When running gst_registry_scan_plugin_file we were losing the
information about the registry being loaded and ended up adding the
plugin to the default registry which was not correct.

https://bugzilla.gnome.org/show_bug.cgi?id=752662

gst/gst_private.h
gst/gstplugin.c
gst/gstregistry.c

index 044fead..6de9013 100644 (file)
@@ -133,6 +133,10 @@ G_GNUC_INTERNAL  void _priv_gst_registry_cleanup (void);
 
 gboolean _gst_plugin_loader_client_run (void);
 
+G_GNUC_INTERNAL  GstPlugin * _priv_gst_plugin_load_file_for_registry (const gchar *filename,
+                                                                      GstRegistry * registry,
+                                                                      GError** error);
+
 /* Used in GstBin for manual state handling */
 G_GNUC_INTERNAL  void _priv_gst_element_state_changed (GstElement *element,
                       GstState oldstate, GstState newstate, GstState pending);
index ba3dd60..4b7a140 100644 (file)
@@ -677,19 +677,27 @@ static GMutex gst_plugin_loading_mutex;
 GstPlugin *
 gst_plugin_load_file (const gchar * filename, GError ** error)
 {
+  return _priv_gst_plugin_load_file_for_registry (filename, NULL, error);
+}
+
+GstPlugin *
+_priv_gst_plugin_load_file_for_registry (const gchar * filename,
+    GstRegistry * registry, GError ** error)
+{
   GstPluginDesc *desc;
   GstPlugin *plugin;
   GModule *module;
   gboolean ret;
   gpointer ptr;
   GStatBuf file_status;
-  GstRegistry *registry;
   gboolean new_plugin = TRUE;
   GModuleFlags flags;
 
   g_return_val_if_fail (filename != NULL, NULL);
 
-  registry = gst_registry_get ();
+  if (registry == NULL)
+    registry = gst_registry_get ();
+
   g_mutex_lock (&gst_plugin_loading_mutex);
 
   plugin = gst_registry_lookup (registry, filename);
@@ -835,7 +843,7 @@ gst_plugin_load_file (const gchar * filename, GError ** error)
 
   if (new_plugin) {
     gst_object_ref (plugin);
-    gst_registry_add_plugin (gst_registry_get (), plugin);
+    gst_registry_add_plugin (registry, plugin);
   }
 
   g_mutex_unlock (&gst_plugin_loading_mutex);
index 27a3f76..090f814 100644 (file)
@@ -1177,7 +1177,8 @@ gst_registry_scan_plugin_file (GstRegistryScanContext * context,
     /* We don't use a GError here because a failure to load some shared
      * objects as plugins is normal (particularly in the uninstalled case)
      */
-    newplugin = gst_plugin_load_file (filename, NULL);
+    newplugin = _priv_gst_plugin_load_file_for_registry (filename,
+        context->registry, NULL);
   }
 
   if (newplugin) {