diff --git a/ChangeLog b/ChangeLog index 477726a138..701e76e776 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2005-10-08 Thomas Vander Stichele + + * gst/gstplugin.c: (gst_plugin_finalize), (gst_plugin_load_file): + * gst/gstplugin.h: + * gst/gstregistry.c: (gst_registry_lookup_locked), + (gst_registry_scan_path_level): + * gst/gstregistryxml.c: (load_plugin): + Only ever load one plugin for a given plugin basename. + This ensures correct overriding of GST_PLUGIN_PATH over + GST_PLUGIN_SYSTEM_PATH and of home dir plugins over + system installed plugins. + 2005-10-08 Wim Taymans * gst/base/gstbasesink.c: (gst_base_sink_handle_object), diff --git a/gst/gstplugin.c b/gst/gstplugin.c index 57fd70e189..71a766d2f9 100644 --- a/gst/gstplugin.c +++ b/gst/gstplugin.c @@ -130,6 +130,7 @@ gst_plugin_finalize (GObject * object) } } g_free (plugin->filename); + g_free (plugin->basename); gst_plugin_desc_free (&plugin->desc); G_OBJECT_CLASS (parent_class)->finalize (object); @@ -413,6 +414,7 @@ gst_plugin_load_file (const gchar * filename, GError ** error) plugin->module = module; plugin->filename = strdup (filename); + plugin->basename = g_path_get_basename (filename); plugin->file_mtime = file_status.st_mtime; plugin->file_size = file_status.st_size; diff --git a/gst/gstplugin.h b/gst/gstplugin.h index 9213af64fc..40a8baebaf 100644 --- a/gst/gstplugin.h +++ b/gst/gstplugin.h @@ -142,11 +142,14 @@ struct _GstPlugin { unsigned int flags; gchar * filename; + gchar * basename; /* base name (non-dir part) of plugin path */ GModule * module; /* contains the module if plugin is loaded */ size_t file_size; time_t file_mtime; + gboolean registered; /* TRUE when the registry has seen a filename + * that matches the plugin's basename */ gpointer _gst_reserved[GST_PADDING]; }; diff --git a/gst/gstregistry.c b/gst/gstregistry.c index dce4f84137..2cb22749af 100644 --- a/gst/gstregistry.c +++ b/gst/gstregistry.c @@ -603,17 +603,21 @@ gst_registry_lookup_locked (GstRegistry * registry, const char *filename) { GList *g; GstPlugin *plugin; + gchar *basename; if (filename == NULL) return NULL; + basename = g_path_get_basename (filename); for (g = registry->plugins; g; g = g_list_next (g)) { plugin = GST_PLUGIN (g->data); - if (plugin->filename && strcmp (filename, plugin->filename) == 0) { + if (plugin->basename && strcmp (basename, plugin->basename) == 0) { + g_free (basename); return plugin; } } + g_free (basename); return NULL; } @@ -685,6 +689,8 @@ gst_registry_scan_path_level (GstRegistry * registry, const gchar * path, continue; } + /* plug-ins are considered unique by basename; if the given name + * was already seen by the registry, we ignore it */ plugin = gst_registry_lookup (registry, filename); if (plugin) { struct stat file_status; @@ -694,7 +700,12 @@ gst_registry_scan_path_level (GstRegistry * registry, const gchar * path, g_free (filename); continue; } - + if (plugin->registered) { + GST_DEBUG_OBJECT (registry, "plugin already registered from path %s", + plugin->filename); + continue; + } + plugin->registered = TRUE; if (plugin->file_mtime == file_status.st_mtime && plugin->file_size == file_status.st_size) { GST_DEBUG_OBJECT (registry, "file %s cached", filename); @@ -713,9 +724,12 @@ gst_registry_scan_path_level (GstRegistry * registry, const gchar * path, gst_object_unref (plugin); } else { + GST_DEBUG_OBJECT (registry, "file %s not yet in registry", filename); newplugin = gst_plugin_load_file (filename, NULL); - if (newplugin) + if (newplugin) { + newplugin->registered = TRUE; gst_object_unref (newplugin); + } } g_free (filename); diff --git a/gst/gstregistryxml.c b/gst/gstregistryxml.c index a53cb64aff..11a4d47167 100644 --- a/gst/gstregistryxml.c +++ b/gst/gstregistryxml.c @@ -654,6 +654,7 @@ load_plugin (xmlTextReaderPtr reader, GList ** feature_list) if (!read_string (reader, &plugin->filename)) break; GST_DEBUG ("filename %s", plugin->filename); + plugin->basename = g_path_get_basename (plugin->filename); } else if (g_str_equal (tag, "version")) { if (!read_string (reader, &plugin->desc.version)) break;