element: Enforce that elements created by gst_element_factory_create/make() are floating
[platform/upstream/gstreamer.git] / gst / gstregistry.c
index f16d2eb..a8b2f51 100644 (file)
@@ -23,6 +23,7 @@
 
 /**
  * SECTION:gstregistry
+ * @title: GstRegistry
  * @short_description: Abstract base class for management of #GstPlugin objects
  * @see_also: #GstPlugin, #GstPluginFeature
  *
  *
  * On startup, plugins are searched for in the plugin search path. The following
  * locations are checked in this order:
- * <itemizedlist>
- *   <listitem>
- *     <para>location from --gst-plugin-path commandline option.</para>
- *   </listitem>
- *   <listitem>
- *     <para>the GST_PLUGIN_PATH environment variable.</para>
- *   </listitem>
- *   <listitem>
- *     <para>the GST_PLUGIN_SYSTEM_PATH environment variable.</para>
- *   </listitem>
- *   <listitem>
- *     <para>default locations (if GST_PLUGIN_SYSTEM_PATH is not set). Those
- *       default locations are:
- *       <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>
+ *
+ * * location from --gst-plugin-path commandline option.
+ * * the GST_PLUGIN_PATH environment variable.
+ * * the GST_PLUGIN_SYSTEM_PATH environment variable.
+ * * default locations (if GST_PLUGIN_SYSTEM_PATH is not set).
+ *   Those default locations are:
+ *   `$XDG_DATA_HOME/gstreamer-$GST_API_VERSION/plugins/`
+ *   and `$prefix/libs/gstreamer-$GST_API_VERSION/`.
+ *   [$XDG_DATA_HOME](http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html) defaults to
+ *   `$HOME/.local/share`.
+ *
  * The registry cache file is loaded from
- * <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
+ * `$XDG_CACHE_HOME/gstreamer-$GST_API_VERSION/registry-$ARCH.bin`
+ * (where $XDG_CACHE_HOME defaults to `$HOME/.cache`) 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:
- * <itemizedlist>
- *   <listitem>
- *     <para>the cache may not contain information about a given file.</para>
- *   </listitem>
- *   <listitem>
- *     <para>the cache may have stale information.</para>
- *   </listitem>
- *   <listitem>
- *     <para>the cache may have current information.</para>
- *   </listitem>
- * </itemizedlist>
+ *
+ *   * the cache may not contain information about a given file.
+ *   * the cache may have stale information.
+ *   * the cache may have current information.
  *
  * In the first two cases, the plugin is loaded and the cache updated. In
  * addition to these cases, the cache may have entries for plugins that are not
@@ -97,7 +78,7 @@
  * checked to make sure the information is minimally valid. If not, the entry is
  * simply dropped.
  *
- * <emphasis role="bold">Implementation notes:</emphasis>
+ * ## Implementation notes:
  *
  * The "cache" and "registry" are different concepts and can represent
  * different sets of plugins. For various reasons, at init time, the cache is
@@ -215,7 +196,7 @@ static GstPlugin *gst_registry_lookup_bn_locked (GstRegistry * registry,
     const char *basename);
 
 #define gst_registry_parent_class parent_class
-G_DEFINE_TYPE (GstRegistry, gst_registry, GST_TYPE_OBJECT);
+G_DEFINE_TYPE_WITH_PRIVATE (GstRegistry, gst_registry, GST_TYPE_OBJECT);
 
 static void
 gst_registry_class_init (GstRegistryClass * klass)
@@ -224,8 +205,6 @@ gst_registry_class_init (GstRegistryClass * klass)
 
   gobject_class = (GObjectClass *) klass;
 
-  g_type_class_add_private (klass, sizeof (GstRegistryPrivate));
-
   /**
    * GstRegistry::plugin-added:
    * @registry: the registry that emitted the signal
@@ -258,9 +237,7 @@ gst_registry_class_init (GstRegistryClass * klass)
 static void
 gst_registry_init (GstRegistry * registry)
 {
-  registry->priv =
-      G_TYPE_INSTANCE_GET_PRIVATE (registry, GST_TYPE_REGISTRY,
-      GstRegistryPrivate);
+  registry->priv = gst_registry_get_instance_private (registry);
   registry->priv->feature_hash = g_hash_table_new (g_str_hash, g_str_equal);
   registry->priv->basename_hash = g_hash_table_new (g_str_hash, g_str_equal);
 }
@@ -346,7 +323,7 @@ gst_registry_get (void)
 
   g_mutex_lock (&_gst_registry_mutex);
   if (G_UNLIKELY (!_gst_registry_default)) {
-    _gst_registry_default = g_object_newv (GST_TYPE_REGISTRY, 0, NULL);
+    _gst_registry_default = g_object_new (GST_TYPE_REGISTRY, NULL);
     gst_object_ref_sink (GST_OBJECT_CAST (_gst_registry_default));
   }
   registry = _gst_registry_default;
@@ -429,10 +406,12 @@ gst_registry_get_path_list (GstRegistry * registry)
 /**
  * gst_registry_add_plugin:
  * @registry: the registry to add the plugin to
- * @plugin: (transfer full): the plugin to add
+ * @plugin: (transfer floating): the plugin to add
  *
  * Add the plugin to the registry. The plugin-added signal will be emitted.
- * This function will sink @plugin.
+ *
+ * @plugin's reference count will be incremented, and any floating
+ * reference will be removed (see gst_object_ref_sink())
  *
  * Returns: %TRUE on success.
  *
@@ -463,6 +442,8 @@ gst_registry_add_plugin (GstRegistry * registry, GstPlugin * plugin)
         GST_WARNING_OBJECT (registry,
             "Not replacing plugin because new one (%s) is blacklisted but for a different location than existing one (%s)",
             plugin->filename, existing_plugin->filename);
+        /* Keep reference counting consistent */
+        gst_object_ref_sink (plugin);
         gst_object_unref (plugin);
         GST_OBJECT_UNLOCK (registry);
         return FALSE;
@@ -559,10 +540,12 @@ gst_registry_remove_plugin (GstRegistry * registry, GstPlugin * plugin)
 /**
  * gst_registry_add_feature:
  * @registry: the registry to add the plugin to
- * @feature: (transfer full): the feature to add
+ * @feature: (transfer floating): the feature to add
  *
  * Add the feature to the registry. The feature-added signal will be emitted.
- * This function sinks @feature.
+ *
+ * @feature's reference count will be incremented, and any floating
+ * reference will be removed (see gst_object_ref_sink())
  *
  * Returns: %TRUE on success.
  *
@@ -1284,7 +1267,7 @@ gst_registry_scan_path_level (GstRegistryScanContext * context,
       g_free (filename);
       continue;
     }
-    if (!g_str_has_suffix (dirent, G_MODULE_SUFFIX)
+    if (!g_str_has_suffix (dirent, "." G_MODULE_SUFFIX)
 #ifdef GST_EXTRA_MODULE_SUFFIX
         && !g_str_has_suffix (dirent, GST_EXTRA_MODULE_SUFFIX)
 #endif
@@ -1388,7 +1371,7 @@ gst_registry_scan_path_internal (GstRegistryScanContext * context,
 /**
  * gst_registry_scan_path:
  * @registry: the registry to add found plugins to
- * @path: the path to scan
+ * @path: (type filename): the path to scan
  *
  * Scan the given path for plugins to add to the registry. The syntax of the
  * path is specific to the registry.
@@ -1660,11 +1643,8 @@ 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,
-#ifdef _DEBUG
-          "debug"
-#endif
-          "lib", "gstreamer-" GST_API_VERSION, NULL);
+      dir = g_build_filename (base_dir, GST_PLUGIN_SUBDIR,
+          "gstreamer-" GST_API_VERSION, NULL);
       GST_DEBUG ("scanning DLL dir %s", dir);
 
       changed |= gst_registry_scan_path_internal (&context, dir);