gst/: Only ever load one plugin for a given plugin basename.
authorThomas Vander Stichele <thomas@apestaart.org>
Sat, 8 Oct 2005 13:57:17 +0000 (13:57 +0000)
committerThomas Vander Stichele <thomas@apestaart.org>
Sat, 8 Oct 2005 13:57:17 +0000 (13:57 +0000)
Original commit message from CVS:

* 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.

ChangeLog
gst/gstplugin.c
gst/gstplugin.h
gst/gstregistry.c
gst/gstregistryxml.c

index 477726a..701e76e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2005-10-08  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+       * 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  <wim@fluendo.com>
 
        * gst/base/gstbasesink.c: (gst_base_sink_handle_object),
index 57fd70e..71a766d 100644 (file)
@@ -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;
 
index 9213af6..40a8bae 100644 (file)
@@ -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];
 };
index dce4f84..2cb2274 100644 (file)
@@ -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);
index a53cb64..11a4d47 100644 (file)
@@ -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;