docs: fix problems introduced by c068b225fef5a9bf0
[platform/upstream/gstreamer.git] / gst / gstregistry.c
index 9fc69d3..dfd87d0 100644 (file)
@@ -17,8 +17,8 @@
  *
  * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
  */
 
 /**
  *
  * The #GstRegistry object is a list of plugins and some functions for dealing
  * with them. Each #GstPlugin is matched 1-1 with a file on disk, and may or may
- * not be loaded at a given time. There may be multiple #GstRegistry objects,
- * but the "default registry" is the only object that has any meaning to the
- * core.
- *
- * The registry file is actually a cache of plugin information. This is
- * unlike versions prior to 0.10, where the registry file was the primary source
- * of plugin information, and was created by the gst-register command.
+ * not be loaded at a given time.
  *
  * The primary source, at all times, of plugin information is each plugin file
  * itself. Thus, if an application wants information about a particular plugin,
  *   <listitem>
  *     <para>default locations (if GST_PLUGIN_SYSTEM_PATH is not set). Those
  *       default locations are:
- *       <filename>~/.gstreamer-$GST_MAJORMINOR/plugins/</filename>
- *       and <filename>$prefix/libs/gstreamer-$GST_MAJORMINOR/</filename>.
+ *       <filename>$XDG_DATA_HOME/gstreamer-$GST_API_VERSION/plugins/</filename>
+ *       and <filename>$prefix/libs/gstreamer-$GST_API_VERSION/</filename>.
+ *       <ulink url="http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html">
+ *       <filename>$XDG_DATA_HOME</filename></ulink> defaults to
+ *       <filename>$HOME/.local/share</filename>.
  *     </para>
  *   </listitem>
  * </itemizedlist>
  * The registry cache file is loaded from
- * <filename>~/.gstreamer-$GST_MAJORMINOR/registry-$ARCH.bin</filename> or the
- * file listed in the GST_REGISTRY env var. One reason to change the registry
- * location is for testing.
+ * <filename>$XDG_CACHE_HOME/gstreamer-$GST_API_VERSION/registry-$ARCH.bin</filename>
+ * (where
+ * <ulink url="http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html">
+ * <filename>$XDG_CACHE_HOME</filename></ulink> defaults to
+ * <filename>$HOME/.cache</filename>) or the file listed in the GST_REGISTRY
+ * env var. One reason to change the registry location is for testing.
  *
  * For each plugin that is found in the plugin search path, there could be 3
  * possibilities for cached information:
  *
  * <emphasis role="bold">Implementation notes:</emphasis>
  *
- * The "cache" and "default registry" are different concepts and can represent
+ * The "cache" and "registry" are different concepts and can represent
  * different sets of plugins. For various reasons, at init time, the cache is
  * stored in the default registry, and plugins not relevant to the current
  * process are marked with the %GST_PLUGIN_FLAG_CACHED bit. These plugins are
  * removed at the end of initialization.
+ *
+ * Last reviewed on 2012-03-29 (0.11.3)
  */
 
 #ifdef HAVE_CONFIG_H
 #include "gstinfo.h"
 #include "gsterror.h"
 #include "gstregistry.h"
-#include "gstmarshal.h"
 
 #include "gstpluginloader.h"
 
@@ -148,7 +149,9 @@ struct _GstRegistryPrivate
   GList *plugins;
   GList *features;
 
+#if 0
   GList *paths;
+#endif
 
   int cache_file;
 
@@ -168,7 +171,7 @@ struct _GstRegistryPrivate
 
 /* the one instance of the default registry and the mutex protecting the
  * variable. */
-static GStaticMutex _gst_registry_mutex = G_STATIC_MUTEX_INIT;
+static GMutex _gst_registry_mutex;
 static GstRegistry *_gst_registry_default = NULL;
 
 /* defaults */
@@ -229,7 +232,7 @@ gst_registry_class_init (GstRegistryClass * klass)
    */
   gst_registry_signals[PLUGIN_ADDED] =
       g_signal_new ("plugin-added", G_TYPE_FROM_CLASS (klass),
-      G_SIGNAL_RUN_LAST, 0, NULL, NULL, gst_marshal_VOID__OBJECT,
+      G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_generic,
       G_TYPE_NONE, 1, GST_TYPE_PLUGIN);
 
   /**
@@ -242,7 +245,7 @@ gst_registry_class_init (GstRegistryClass * klass)
    */
   gst_registry_signals[FEATURE_ADDED] =
       g_signal_new ("feature-added", G_TYPE_FROM_CLASS (klass),
-      G_SIGNAL_RUN_LAST, 0, NULL, NULL, gst_marshal_VOID__OBJECT,
+      G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_generic,
       G_TYPE_NONE, 1, GST_TYPE_PLUGIN_FEATURE);
 
   gobject_class->finalize = gst_registry_finalize;
@@ -330,17 +333,18 @@ gst_registry_get (void)
 {
   GstRegistry *registry;
 
-  g_static_mutex_lock (&_gst_registry_mutex);
+  g_mutex_lock (&_gst_registry_mutex);
   if (G_UNLIKELY (!_gst_registry_default)) {
     _gst_registry_default = g_object_newv (GST_TYPE_REGISTRY, 0, NULL);
     gst_object_ref_sink (GST_OBJECT_CAST (_gst_registry_default));
   }
   registry = _gst_registry_default;
-  g_static_mutex_unlock (&_gst_registry_mutex);
+  g_mutex_unlock (&_gst_registry_mutex);
 
   return registry;
 }
 
+#if 0
 /**
  * gst_registry_add_path:
  * @registry: the registry to add the path to
@@ -409,7 +413,7 @@ gst_registry_get_path_list (GstRegistry * registry)
 
   return list;
 }
-
+#endif
 
 /**
  * gst_registry_add_plugin:
@@ -443,7 +447,7 @@ gst_registry_add_plugin (GstRegistry * registry, GstPlugin * plugin)
           GST_STR_NULL (plugin->filename));
       /* If the new plugin is blacklisted and the existing one isn't cached, do not
        * accept if it's from a different location than the existing one */
-      if ((plugin->flags & GST_PLUGIN_FLAG_BLACKLISTED) &&
+      if (GST_OBJECT_FLAG_IS_SET (plugin, GST_PLUGIN_FLAG_BLACKLISTED) &&
           strcmp (plugin->filename, existing_plugin->filename)) {
         GST_WARNING_OBJECT (registry,
             "Not replacing plugin because new one (%s) is blacklisted but for a different location than existing one (%s)",
@@ -821,6 +825,12 @@ gst_registry_feature_filter (GstRegistry * registry,
   return list;
 }
 
+static gboolean
+gst_registry_plugin_name_filter (GstPlugin * plugin, const gchar * name)
+{
+  return (plugin->desc.name && !strcmp (plugin->desc.name, name));
+}
+
 /**
  * gst_registry_find_plugin:
  * @registry: the registry to search
@@ -844,7 +854,7 @@ gst_registry_find_plugin (GstRegistry * registry, const gchar * name)
   g_return_val_if_fail (name != NULL, NULL);
 
   walk = gst_registry_plugin_filter (registry,
-      (GstPluginFilter) gst_plugin_name_filter, TRUE, (gpointer) name);
+      (GstPluginFilter) gst_registry_plugin_name_filter, TRUE, (gpointer) name);
   if (walk) {
     result = GST_PLUGIN_CAST (walk->data);
 
@@ -1120,10 +1130,9 @@ gst_registry_scan_plugin_file (GstRegistryScanContext * context,
             filename, file_size, file_mtime)) {
       g_warning ("External plugin loader failed. This most likely means that "
           "the plugin loader helper binary was not found or could not be run. "
-          "%s", (g_getenv ("GST_PLUGIN_PATH") != NULL) ?
-          "If you are running an uninstalled GStreamer setup, you might need "
-          "to update your gst-uninstalled script so that the "
-          "GST_PLUGIN_SCANNER environment variable gets set." : "");
+          "You might need to set the GST_PLUGIN_SCANNER environment variable "
+          "if your setup is unusual. This should normally not be required "
+          "though.");
       context->helper_state = REGISTRY_SCAN_HELPER_DISABLED;
     }
   }
@@ -1145,11 +1154,12 @@ gst_registry_scan_plugin_file (GstRegistryScanContext * context,
     gst_object_unref (newplugin);
     changed = TRUE;
   }
-
+#ifndef GST_DISABLE_REGISTRY
   if (!__registry_reuse_plugin_scanner) {
     clear_scan_context (context);
     context->helper_state = REGISTRY_SCAN_HELPER_NOT_STARTED;
   }
+#endif
 
   return changed;
 }
@@ -1276,7 +1286,7 @@ gst_registry_scan_path_level (GstRegistryScanContext * context,
           !(deps_changed = _priv_plugin_deps_files_changed (plugin)) &&
           !strcmp (plugin->filename, filename)) {
         GST_LOG_OBJECT (context->registry, "file %s cached", filename);
-        plugin->flags &= ~GST_PLUGIN_FLAG_CACHED;
+        GST_OBJECT_FLAG_UNSET (plugin, GST_PLUGIN_FLAG_CACHED);
         GST_LOG_OBJECT (context->registry,
             "marking plugin %p as registered as %s", plugin, filename);
         plugin->registered = TRUE;
@@ -1388,11 +1398,11 @@ _priv_gst_registry_cleanup (void)
 {
   GstRegistry *registry;
 
-  g_static_mutex_lock (&_gst_registry_mutex);
+  g_mutex_lock (&_gst_registry_mutex);
   if ((registry = _gst_registry_default) != NULL) {
     _gst_registry_default = NULL;
   }
-  g_static_mutex_unlock (&_gst_registry_mutex);
+  g_mutex_unlock (&_gst_registry_mutex);
 
   /* unref outside of the lock because we can. */
   if (registry)
@@ -1485,7 +1495,7 @@ gst_registry_remove_cache_plugins (GstRegistry * registry)
   while (g) {
     g_next = g->next;
     plugin = g->data;
-    if (plugin->flags & GST_PLUGIN_FLAG_CACHED) {
+    if (GST_OBJECT_FLAG_IS_SET (plugin, GST_PLUGIN_FLAG_CACHED)) {
       GST_DEBUG_OBJECT (registry, "removing cached plugin \"%s\"",
           GST_STR_NULL (plugin->filename));
       registry->priv->plugins = g_list_delete_link (registry->priv->plugins, g);
@@ -1551,7 +1561,9 @@ scan_and_update_registry (GstRegistry * default_registry,
 
   /* GST_PLUGIN_PATH specifies a list of directories to scan for
    * additional plugins.  These take precedence over the system plugins */
-  plugin_path = g_getenv ("GST_PLUGIN_PATH");
+  plugin_path = g_getenv ("GST_PLUGIN_PATH_1_0");
+  if (plugin_path == NULL)
+    plugin_path = g_getenv ("GST_PLUGIN_PATH");
   if (plugin_path) {
     char **list;
     int i;
@@ -1569,7 +1581,9 @@ scan_and_update_registry (GstRegistry * default_registry,
   /* GST_PLUGIN_SYSTEM_PATH specifies a list of plugins that are always
    * loaded by default.  If not set, this defaults to the system-installed
    * path, and the plugins installed in the user's home directory */
-  plugin_path = g_getenv ("GST_PLUGIN_SYSTEM_PATH");
+  plugin_path = g_getenv ("GST_PLUGIN_SYSTEM_PATH_1_0");
+  if (plugin_path == NULL)
+    plugin_path = g_getenv ("GST_PLUGIN_SYSTEM_PATH");
   if (plugin_path == NULL) {
     char *home_plugins;
 
@@ -1578,15 +1592,13 @@ scan_and_update_registry (GstRegistry * default_registry,
     /* plugins in the user's home directory take precedence over
      * system-installed ones */
     home_plugins = g_build_filename (g_get_user_data_dir (),
-        "gstreamer-" GST_MAJORMINOR, "plugins", NULL);
+        "gstreamer-" GST_API_VERSION, "plugins", NULL);
 
     GST_DEBUG ("scanning home plugins %s", home_plugins);
     changed |= gst_registry_scan_path_internal (&context, home_plugins);
     g_free (home_plugins);
 
     /* add the main (installed) library path */
-    GST_DEBUG ("scanning main plugins %s", PLUGINDIR);
-    changed |= gst_registry_scan_path_internal (&context, PLUGINDIR);
 
 #ifdef G_OS_WIN32
     {
@@ -1597,7 +1609,14 @@ scan_and_update_registry (GstRegistry * default_registry,
           g_win32_get_package_installation_directory_of_module
           (_priv_gst_dll_handle);
 
-      dir = g_build_filename (base_dir, "lib", "gstreamer-0.10", NULL);
+      dir =
+          g_build_filename (base_dir,
+#ifdef _DEBUG
+                            "debug"
+#endif
+                            "lib",
+                            "gstreamer-" GST_API_VERSION,
+                            NULL);
       GST_DEBUG ("scanning DLL dir %s", dir);
 
       changed |= gst_registry_scan_path_internal (&context, dir);
@@ -1605,6 +1624,9 @@ scan_and_update_registry (GstRegistry * default_registry,
       g_free (dir);
       g_free (base_dir);
     }
+#else
+    GST_DEBUG ("scanning main plugins %s", PLUGINDIR);
+    changed |= gst_registry_scan_path_internal (&context, PLUGINDIR);
 #endif
   } else {
     gchar **list;
@@ -1657,10 +1679,13 @@ ensure_current_registry (GError ** error)
   gboolean have_cache = TRUE;
 
   default_registry = gst_registry_get ();
-  registry_file = g_strdup (g_getenv ("GST_REGISTRY"));
+
+  registry_file = g_strdup (g_getenv ("GST_REGISTRY_1_0"));
+  if (registry_file == NULL)
+    registry_file = g_strdup (g_getenv ("GST_REGISTRY"));
   if (registry_file == NULL) {
     registry_file = g_build_filename (g_get_user_cache_dir (),
-        "gstreamer-" GST_MAJORMINOR, "registry." HOST_CPU ".bin", NULL);
+        "gstreamer-" GST_API_VERSION, "registry." TARGET_CPU ".bin", NULL);
   }
 
   if (!_gst_disable_registry_cache) {
@@ -1717,8 +1742,6 @@ ensure_current_registry (GError ** error)
  *
  * Returns: %TRUE if GStreamer will use the child helper process when
  * rebuilding the registry.
- *
- * Since: 0.10.10
  */
 gboolean
 gst_registry_fork_is_enabled (void)
@@ -1733,8 +1756,6 @@ gst_registry_fork_is_enabled (void)
  * Applications might want to disable/enable spawning of a child helper process
  * when rebuilding the registry. See gst_registry_fork_is_enabled() for more
  * information.
- *
- * Since: 0.10.10
  */
 void
 gst_registry_fork_set_enabled (gboolean enabled)
@@ -1764,8 +1785,6 @@ gst_registry_fork_set_enabled (gboolean enabled)
  *
  * Returns: %TRUE if the registry has been updated successfully (does not
  *          imply that there were changes), otherwise %FALSE.
- *
- * Since: 0.10.12
  */
 gboolean
 gst_update_registry (void)
@@ -1800,12 +1819,10 @@ gst_update_registry (void)
  * gst_registry_get_feature_list_cookie:
  * @registry: the registry
  *
- * Returns the registrys feature list cookie. This changes
+ * Returns the registry's feature list cookie. This changes
  * every time a feature is added or removed from the registry.
  *
  * Returns: the feature list cookie.
- *
- * Since: 0.10.26
  */
 guint32
 gst_registry_get_feature_list_cookie (GstRegistry * registry)