2005-09-22 Andy Wingo <wingo@pobox.com>
+ * gst/gstconfig.h.in: Psych out gtk-doc.
+
+ * docs/gst/gstreamer-sections.txt: Add GST_HAVE_GLIB_2_8.
+
+ * check/Makefile.am (check_PROGRAMS): Add gstplugin to the tests.
+
+ * tools/gst-inspect.c (print_element_list): Plug some
+ inconsequential leaks.
+
+ * gst/gstregistry.c (gst_registry_get_default): Doc.
+
+ * check/gst/gstplugin.c:
+ * gst/gsttypefindfactory.c (gst_type_find_factory_call_function):
+ * gst/gstelementfactory.c (gst_element_factory_create):
+ * gst/gstindexfactory.c (gst_index_factory_create): Update for
+ refcount changes.
+
+ * gst/gstpluginfeature.c (gst_plugin_feature_list_free): Doc.
+ (gst_plugin_feature_load): Doc, don't eat refs.
+
+ * gst/gstplugin.c (gst_plugin_load): Doc, don't eat refs.
+ (gst_plugin_list_free): Doc.
+ (gst_plugin_load_file): Doc updates.
+
* gst/gstbuffer.c (gst_buffer_get_caps): Like all our _get
accessors returning refcounted objects, return a ref.
gst/gstobject \
gst/gstpad \
gst/gstpipeline \
+ gst/gstplugin \
gst/gstsystemclock \
gst/gststructure \
gst/gsttag \
for (g = registry->plugins; g; g = g->next) {
GstPlugin *plugin = GST_PLUGIN (g->data);
- fail_if (GST_OBJECT (plugin)->refcount != 1,
+ fail_if (GST_OBJECT_REFCOUNT_VALUE (plugin) != 1,
"Plugin in registry should have refcount of 1");
- GST_DEBUG ("refcount %d %s", GST_OBJECT (plugin)->refcount,
+ GST_DEBUG ("refcount %d %s", GST_OBJECT_REFCOUNT_VALUE (plugin),
plugin->desc.name);
}
for (g = registry->features; g; g = g->next) {
GstPluginFeature *feature = GST_PLUGIN_FEATURE (g->data);
- fail_if (GST_OBJECT (feature)->refcount != 1,
+ fail_if (GST_OBJECT_REFCOUNT_VALUE (feature) != 1,
"Feature in registry should have refcount of 1");
- GST_DEBUG ("refcount %d %s", GST_OBJECT (feature)->refcount, feature->name);
+ GST_DEBUG ("refcount %d %s", GST_OBJECT_REFCOUNT_VALUE (feature),
+ feature->name);
}
}
unloaded_plugin = gst_default_registry_find_plugin ("gstelements");
fail_if (unloaded_plugin == NULL, "Failed to find gstelements plugin");
- fail_if (GST_OBJECT (unloaded_plugin)->refcount != 2,
+ fail_if (GST_OBJECT_REFCOUNT_VALUE (unloaded_plugin) != 2,
"Refcount of unloaded plugin in registry initially should be 2");
- GST_DEBUG ("refcount %d", GST_OBJECT (unloaded_plugin)->refcount);
+ GST_DEBUG ("refcount %d", GST_OBJECT_REFCOUNT_VALUE (unloaded_plugin));
- gst_object_ref (unloaded_plugin);
loaded_plugin = gst_plugin_load (unloaded_plugin);
fail_if (loaded_plugin == NULL, "Failed to load plugin");
if (loaded_plugin != unloaded_plugin) {
- fail_if (GST_OBJECT (loaded_plugin)->refcount != 2,
+ fail_if (GST_OBJECT_REFCOUNT_VALUE (loaded_plugin) != 2,
"Refcount of loaded plugin in registry should be 2");
- GST_DEBUG ("refcount %d", GST_OBJECT (loaded_plugin)->refcount);
- fail_if (GST_OBJECT (unloaded_plugin)->refcount != 1,
+ GST_DEBUG ("refcount %d", GST_OBJECT_REFCOUNT_VALUE (loaded_plugin));
+ fail_if (GST_OBJECT_REFCOUNT_VALUE (unloaded_plugin) != 1,
"Refcount of replaced plugin should be 1");
- GST_DEBUG ("refcount %d", GST_OBJECT (unloaded_plugin)->refcount);
+ GST_DEBUG ("refcount %d", GST_OBJECT_REFCOUNT_VALUE (unloaded_plugin));
}
gst_object_unref (unloaded_plugin);
GstPlugin *plugin;
plugin = gst_default_registry_find_plugin ("gstelements");
- fail_if (GST_OBJECT (plugin)->refcount != 2,
+ fail_if (GST_OBJECT_REFCOUNT_VALUE (plugin) != 2,
"Refcount of plugin in registry should be 2");
list = gst_registry_get_plugin_list (gst_registry_get_default ());
- fail_if (plugin->object.refcount != 3,
+ fail_if (GST_OBJECT_REFCOUNT_VALUE (plugin) != 3,
"Refcount of plugin in registry+list should be 3");
gst_plugin_list_free (list);
- fail_if (GST_OBJECT (plugin)->refcount != 2,
+ fail_if (GST_OBJECT_REFCOUNT_VALUE (plugin) != 2,
"Refcount of plugin in after list free should be 2");
gst_object_unref (plugin);
fail_if (strcmp (feature->plugin_name, "gstelements"),
"Expected identity to be from gstelements plugin");
- fail_if (GST_OBJECT (feature)->refcount != 2,
+ fail_if (GST_OBJECT_REFCOUNT_VALUE (feature) != 2,
"Refcount of feature should be 2");
- GST_DEBUG ("refcount %d", GST_OBJECT (feature)->refcount);
+ GST_DEBUG ("refcount %d", GST_OBJECT_REFCOUNT_VALUE (feature));
gst_object_unref (feature);
}
element_factory = gst_element_factory_find ("identity");
fail_if (element_factory == NULL, "Failed to find identity element factory");
- fail_if (GST_OBJECT (element_factory)->refcount != 2,
+ fail_if (GST_OBJECT_REFCOUNT_VALUE (element_factory) != 2,
"Refcount of plugin in registry+feature should be 2");
gst_object_unref (element_factory);
plugin = gst_default_registry_find_plugin ("typefindfunctions");
fail_if (plugin == NULL, "Failed to find typefind functions");
- fail_if (plugin->object.refcount != 2,
+ fail_if (GST_OBJECT_REFCOUNT_VALUE (plugin) != 2,
"Refcount of plugin in registry should be 2");
fail_if (gst_plugin_is_loaded (plugin), "Expected plugin to be unloaded");
fail_if (feature->plugin != plugin,
"Expected identity to be from gstelements plugin");
- fail_if (plugin->object.refcount != 3,
+ fail_if (GST_OBJECT_REFCOUNT_VALUE (plugin) != 3,
"Refcount of plugin in registry+feature should be 3");
gst_type_find_factory_call_function (GST_TYPE_FIND_FACTORY (feature),
gst_object_unref (feature->plugin);
- fail_if (plugin->object.refcount != 1,
+ fail_if (GST_OBJECT_REFCOUNT_VALUE (plugin) != 1,
"Refcount of plugin in after list free should be 1");
gst_object_unref (plugin);
GST_DISABLE_INDEX
GST_DISABLE_PLUGIN
GST_DISABLE_URI
+GST_HAVE_GLIB_2_8
GST_PTR_FORMAT
GST_EXPORT
GST_PLUGIN_EXPORT
#define GST_DISABLE_INDEX 1
#define GST_DISABLE_PLUGIN 1
#define GST_DISABLE_URI 1
+#define GST_HAVE_GLIB_2_8 1
#endif
/***** default padding of structures *****/
GST_ELEMENT_FACTORY (gst_plugin_feature_load (GST_PLUGIN_FEATURE
(factory)));
if (newfactory == NULL) {
- /* it could be factory is invalid. with ref-eating functions nothing is
- certain! */
- GST_WARNING ("loading the plugin for factory %p returned NULL", factory);
+ GST_WARNING_OBJECT (factory, "loading plugin returned NULL!");
return NULL;
- } else if (newfactory != factory) {
- /* gst_plugin_feature_load ate the ref we added to the factory */
- factory = newfactory;
} else {
- /* strip off our extra ref */
gst_object_unref (factory);
factory = newfactory;
}
GstIndex *
gst_index_factory_create (GstIndexFactory * factory)
{
+ GstIndexFactory *newfactory;
GstIndex *new = NULL;
g_return_val_if_fail (factory != NULL, NULL);
- factory =
+ newfactory =
GST_INDEX_FACTORY (gst_plugin_feature_load (GST_PLUGIN_FEATURE
(factory)));
- if (factory == NULL)
+ if (newfactory == NULL)
return NULL;
- new = GST_INDEX (g_object_new (factory->type, NULL));
+ new = GST_INDEX (g_object_new (newfactory->type, NULL));
+
+ gst_object_unref (newfactory);
return new;
}
*
* Loads the given plugin and refs it. Caller needs to unref after use.
*
- * Returns: a new GstPlugin or NULL, if an error occurred.
+ * Returns: a reference to the existing loaded GstPlugin, a reference to the
+ * newly-loaded GstPlugin, or NULL if an error occurred.
*/
GstPlugin *
gst_plugin_load_file (const gchar * filename, GError ** error)
return plugin;
} else {
gst_object_unref (plugin);
+ plugin = NULL;
}
}
return NULL;
}
+/**
+ * gst_plugin_load:
+ * @plugin: plugin to load
+ *
+ * Loads @plugin. Note that the *return value* is the loaded plugin; @plugin is
+ * untouched. The normal use pattern of this function goes like this:
+ *
+ * <programlisting>
+ * GstPlugin *loaded_plugin;
+ * loaded_plugin = gst_plugin_load (plugin);
+ *
+ * // presumably, we're no longer interested in the potentially-unloaded plugin
+ * gst_object_unref (plugin);
+ * plugin = loaded_plugin;
+ * </programlisting>
+ *
+ * Returns: A reference to a loaded plugin, or NULL on error.
+ */
GstPlugin *
gst_plugin_load (GstPlugin * plugin)
{
return plugin;
}
- newplugin = gst_plugin_load_file (plugin->filename, &error);
- if (newplugin == NULL) {
+ if (!(newplugin = gst_plugin_load_file (plugin->filename, &error)))
+ goto load_error;
+
+ return newplugin;
+
+load_error:
+ {
GST_WARNING ("load_plugin error: %s\n", error->message);
g_error_free (error);
- gst_object_unref (plugin);
return NULL;
}
-
- gst_object_unref (plugin);
-
- return newplugin;
}
+/**
+ * gst_plugin_list_free:
+ * @list: list of #GstPlugin
+ *
+ * Unrefs each member of @list, then frees the list.
+ */
void
gst_plugin_list_free (GList * list)
{
* gst_plugin_feature_load:
* @feature: the plugin feature to check
*
- * Check if the plugin containing the feature is loaded,
- * if not, the plugin will be loaded.
+ * Loads the plugin containing @feature if it's not already loaded. @feature is
+ * unaffected; use the return value instead.
*
- * Returns: The new feature
+ * Normally this function is used like this:
+ *
+ * <programlisting>
+ * GstPluginFeature *loaded_feature;
+ * loaded_feature = gst_plugin_feature_load (feature);
+ *
+ * // presumably, we're no longer interested in the potentially-unloaded feature
+ * gst_object_unref (feature);
+ * feature = loaded_feature;
+ * </programlisting>
+ *
+ * Returns: A reference to the loaded feature, or NULL on error.
*/
GstPluginFeature *
gst_plugin_feature_load (GstPluginFeature * feature)
("Loaded plugin containing feature '%s', but feature disappeared.",
feature->name);
}
- gst_object_unref (feature);
return real_feature;
}
return feature->rank;
}
+/**
+ * gst_plugin_feature_list_free:
+ * @list: list of #GstPluginFeature
+ *
+ * Unrefs each member of @list, then frees the list.
+ */
void
gst_plugin_feature_list_free (GList * list)
{
G_OBJECT_CLASS (parent_class)->finalize (object);
}
+/**
+ * gst_registry_get_default:
+ *
+ * Retrieves the default registry. The caller does not own a reference on the
+ * registry, as it is alive as long as GStreamer is initialized.
+ */
GstRegistry *
gst_registry_get_default (void)
{
g_return_if_fail (find->peek != NULL);
g_return_if_fail (find->suggest != NULL);
- /* gst_plugin_feature_load will steal our ref */
- gst_object_ref (factory);
new_factory =
GST_TYPE_FIND_FACTORY (gst_plugin_feature_load (GST_PLUGIN_FEATURE
(factory)));
gst/gstobject \
gst/gstpad \
gst/gstpipeline \
+ gst/gstplugin \
gst/gstsystemclock \
gst/gststructure \
gst/gsttag \
for (g = registry->plugins; g; g = g->next) {
GstPlugin *plugin = GST_PLUGIN (g->data);
- fail_if (GST_OBJECT (plugin)->refcount != 1,
+ fail_if (GST_OBJECT_REFCOUNT_VALUE (plugin) != 1,
"Plugin in registry should have refcount of 1");
- GST_DEBUG ("refcount %d %s", GST_OBJECT (plugin)->refcount,
+ GST_DEBUG ("refcount %d %s", GST_OBJECT_REFCOUNT_VALUE (plugin),
plugin->desc.name);
}
for (g = registry->features; g; g = g->next) {
GstPluginFeature *feature = GST_PLUGIN_FEATURE (g->data);
- fail_if (GST_OBJECT (feature)->refcount != 1,
+ fail_if (GST_OBJECT_REFCOUNT_VALUE (feature) != 1,
"Feature in registry should have refcount of 1");
- GST_DEBUG ("refcount %d %s", GST_OBJECT (feature)->refcount, feature->name);
+ GST_DEBUG ("refcount %d %s", GST_OBJECT_REFCOUNT_VALUE (feature),
+ feature->name);
}
}
unloaded_plugin = gst_default_registry_find_plugin ("gstelements");
fail_if (unloaded_plugin == NULL, "Failed to find gstelements plugin");
- fail_if (GST_OBJECT (unloaded_plugin)->refcount != 2,
+ fail_if (GST_OBJECT_REFCOUNT_VALUE (unloaded_plugin) != 2,
"Refcount of unloaded plugin in registry initially should be 2");
- GST_DEBUG ("refcount %d", GST_OBJECT (unloaded_plugin)->refcount);
+ GST_DEBUG ("refcount %d", GST_OBJECT_REFCOUNT_VALUE (unloaded_plugin));
- gst_object_ref (unloaded_plugin);
loaded_plugin = gst_plugin_load (unloaded_plugin);
fail_if (loaded_plugin == NULL, "Failed to load plugin");
if (loaded_plugin != unloaded_plugin) {
- fail_if (GST_OBJECT (loaded_plugin)->refcount != 2,
+ fail_if (GST_OBJECT_REFCOUNT_VALUE (loaded_plugin) != 2,
"Refcount of loaded plugin in registry should be 2");
- GST_DEBUG ("refcount %d", GST_OBJECT (loaded_plugin)->refcount);
- fail_if (GST_OBJECT (unloaded_plugin)->refcount != 1,
+ GST_DEBUG ("refcount %d", GST_OBJECT_REFCOUNT_VALUE (loaded_plugin));
+ fail_if (GST_OBJECT_REFCOUNT_VALUE (unloaded_plugin) != 1,
"Refcount of replaced plugin should be 1");
- GST_DEBUG ("refcount %d", GST_OBJECT (unloaded_plugin)->refcount);
+ GST_DEBUG ("refcount %d", GST_OBJECT_REFCOUNT_VALUE (unloaded_plugin));
}
gst_object_unref (unloaded_plugin);
GstPlugin *plugin;
plugin = gst_default_registry_find_plugin ("gstelements");
- fail_if (GST_OBJECT (plugin)->refcount != 2,
+ fail_if (GST_OBJECT_REFCOUNT_VALUE (plugin) != 2,
"Refcount of plugin in registry should be 2");
list = gst_registry_get_plugin_list (gst_registry_get_default ());
- fail_if (plugin->object.refcount != 3,
+ fail_if (GST_OBJECT_REFCOUNT_VALUE (plugin) != 3,
"Refcount of plugin in registry+list should be 3");
gst_plugin_list_free (list);
- fail_if (GST_OBJECT (plugin)->refcount != 2,
+ fail_if (GST_OBJECT_REFCOUNT_VALUE (plugin) != 2,
"Refcount of plugin in after list free should be 2");
gst_object_unref (plugin);
fail_if (strcmp (feature->plugin_name, "gstelements"),
"Expected identity to be from gstelements plugin");
- fail_if (GST_OBJECT (feature)->refcount != 2,
+ fail_if (GST_OBJECT_REFCOUNT_VALUE (feature) != 2,
"Refcount of feature should be 2");
- GST_DEBUG ("refcount %d", GST_OBJECT (feature)->refcount);
+ GST_DEBUG ("refcount %d", GST_OBJECT_REFCOUNT_VALUE (feature));
gst_object_unref (feature);
}
element_factory = gst_element_factory_find ("identity");
fail_if (element_factory == NULL, "Failed to find identity element factory");
- fail_if (GST_OBJECT (element_factory)->refcount != 2,
+ fail_if (GST_OBJECT_REFCOUNT_VALUE (element_factory) != 2,
"Refcount of plugin in registry+feature should be 2");
gst_object_unref (element_factory);
plugin = gst_default_registry_find_plugin ("typefindfunctions");
fail_if (plugin == NULL, "Failed to find typefind functions");
- fail_if (plugin->object.refcount != 2,
+ fail_if (GST_OBJECT_REFCOUNT_VALUE (plugin) != 2,
"Refcount of plugin in registry should be 2");
fail_if (gst_plugin_is_loaded (plugin), "Expected plugin to be unloaded");
fail_if (feature->plugin != plugin,
"Expected identity to be from gstelements plugin");
- fail_if (plugin->object.refcount != 3,
+ fail_if (GST_OBJECT_REFCOUNT_VALUE (plugin) != 3,
"Refcount of plugin in registry+feature should be 3");
gst_type_find_factory_call_function (GST_TYPE_FIND_FACTORY (feature),
gst_object_unref (feature->plugin);
- fail_if (plugin->object.refcount != 1,
+ fail_if (GST_OBJECT_REFCOUNT_VALUE (plugin) != 1,
"Refcount of plugin in after list free should be 1");
gst_object_unref (plugin);
static void
print_element_list (gboolean print_all)
{
- GList *plugins;
+ GList *plugins, *orig_plugins;
- plugins = gst_default_registry_get_plugin_list ();
+ orig_plugins = plugins = gst_default_registry_get_plugin_list ();
while (plugins) {
- GList *features;
+ GList *features, *orig_features;
GstPlugin *plugin;
plugin = (GstPlugin *) (plugins->data);
plugins = g_list_next (plugins);
- features =
+ orig_features = features =
gst_registry_get_feature_list_by_plugin (gst_registry_get_default (),
plugin->desc.name);
while (features) {
features = g_list_next (features);
}
+
+ gst_plugin_feature_list_free (orig_features);
}
+
+ gst_plugin_list_free (plugins);
}
static void
print_signal_info (element);
print_children_info (element);
+ gst_object_unref (factory);
+
if (_name != "")
g_free (_name);