From 749810b238396c608c6992d3fb6745f892df4541 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Tue, 21 Jul 2015 13:35:33 +0200 Subject: [PATCH] registry: Add plugins to the registry we are loading and not default one 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 | 4 ++++ gst/gstplugin.c | 14 +++++++++++--- gst/gstregistry.c | 3 ++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/gst/gst_private.h b/gst/gst_private.h index 044feada03..6de9013ec7 100644 --- a/gst/gst_private.h +++ b/gst/gst_private.h @@ -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); diff --git a/gst/gstplugin.c b/gst/gstplugin.c index ba3dd60286..4b7a14005d 100644 --- a/gst/gstplugin.c +++ b/gst/gstplugin.c @@ -676,6 +676,13 @@ 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; @@ -683,13 +690,14 @@ gst_plugin_load_file (const gchar * filename, GError ** error) 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); diff --git a/gst/gstregistry.c b/gst/gstregistry.c index 27a3f76e98..090f81409e 100644 --- a/gst/gstregistry.c +++ b/gst/gstregistry.c @@ -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) {