pluginfeature: avoid duplicating feature->name

The feature name is not supposed to change over time anyway. In order to enforce
this parentize features to the registry and make the feature->name pointing to
GstObject:name. In 0.11 we could consider of removing the feature->name variable
(FIXME comment added).

Fixes: #459466
This commit is contained in:
Stefan Kost 2011-04-28 11:34:39 +03:00
parent 9ff4ec3104
commit bd302bb63d
4 changed files with 16 additions and 18 deletions

View file

@ -65,7 +65,6 @@ gst_plugin_feature_finalize (GObject * object)
GST_DEBUG ("finalizing feature %p: '%s'", feature,
GST_PLUGIN_FEATURE_NAME (feature));
g_free (feature->name);
if (feature->plugin != NULL) {
g_object_remove_weak_pointer ((GObject *) feature->plugin,
@ -85,7 +84,7 @@ gst_plugin_feature_finalize (GObject * object)
* Normally this function is used like this:
* |[
* 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);
@ -184,12 +183,12 @@ gst_plugin_feature_set_name (GstPluginFeature * feature, const gchar * name)
g_return_if_fail (GST_IS_PLUGIN_FEATURE (feature));
g_return_if_fail (name != NULL);
if (feature->name) {
if (G_UNLIKELY (feature->name)) {
g_return_if_fail (strcmp (feature->name, name) == 0);
} else {
feature->name = g_strdup (name);
gst_object_set_name (GST_OBJECT (feature), name);
feature->name = GST_OBJECT_NAME (GST_OBJECT (feature));
}
gst_object_set_name (GST_OBJECT_CAST (feature), feature->name);
}
/**

View file

@ -81,7 +81,7 @@ struct _GstPluginFeature {
/*< private >*/
gboolean loaded;
gchar *name;
gchar *name; /* FIXME-0.11: remove variable, we use GstObject:name */
guint rank;
const gchar *plugin_name;

View file

@ -46,7 +46,7 @@
* means of doing so is to load every plugin and look at the resulting
* information that is gathered in the default registry. Clearly, this is a time
* consuming process, so we cache information in the registry file. The format
* and location of the cache file is internal to gstreamer.
* and location of the cache file is internal to gstreamer.
*
* On startup, plugins are searched for in the plugin search path. The following
* locations are checked in this order:
@ -280,7 +280,7 @@ gst_registry_finalize (GObject * object)
if (feature) {
GST_LOG_OBJECT (registry, "removing feature %p (%s)",
feature, gst_plugin_feature_get_name (feature));
gst_object_unref (feature);
gst_object_unparent (GST_OBJECT_CAST (feature));
}
f = g_list_next (f);
}
@ -485,7 +485,7 @@ gst_registry_remove_features_for_plugin_unlocked (GstRegistry * registry,
registry->features = g_list_delete_link (registry->features, f);
g_hash_table_remove (registry->feature_hash, feature->name);
gst_object_unref (feature);
gst_object_unparent (GST_OBJECT_CAST (feature));
}
f = next;
}
@ -561,10 +561,10 @@ gst_registry_add_feature (GstRegistry * registry, GstPluginFeature * feature)
if (G_UNLIKELY (existing_feature)) {
/* We unref now. No need to remove the feature name from the hash table, it
* got replaced by the new feature */
gst_object_unref (existing_feature);
gst_object_unparent (GST_OBJECT_CAST (existing_feature));
}
gst_object_ref_sink (feature);
gst_object_set_parent (GST_OBJECT_CAST (feature), GST_OBJECT_CAST (registry));
registry->priv->cookie++;
GST_OBJECT_UNLOCK (registry);
@ -598,7 +598,8 @@ gst_registry_remove_feature (GstRegistry * registry, GstPluginFeature * feature)
g_hash_table_remove (registry->feature_hash, feature->name);
registry->priv->cookie++;
GST_OBJECT_UNLOCK (registry);
gst_object_unref (feature);
gst_object_unparent ((GstObject *) feature);
}
/**

View file

@ -532,8 +532,9 @@ gst_registry_chunks_load_feature (GstRegistry * registry, gchar ** in,
GstRegistryChunkPluginFeature *pf = NULL;
GstPluginFeature *feature = NULL;
const gchar *const_str, *type_name;
const gchar *feature_name;
const gchar *plugin_name;
gchar *str, *feature_name;
gchar *str;
GType type;
guint i;
@ -548,7 +549,7 @@ gst_registry_chunks_load_feature (GstRegistry * registry, gchar ** in,
}
/* unpack more plugin feature strings */
unpack_string (*in, feature_name, end, fail);
unpack_string_nocopy (*in, feature_name, end, fail);
GST_DEBUG ("Plugin '%s' feature '%s' typename : '%s'", plugin_name,
feature_name, type_name);
@ -556,16 +557,13 @@ gst_registry_chunks_load_feature (GstRegistry * registry, gchar ** in,
if (G_UNLIKELY (!(type = g_type_from_name (type_name)))) {
GST_ERROR ("Unknown type from typename '%s' for plugin '%s'", type_name,
plugin_name);
g_free (feature_name);
return FALSE;
}
if (G_UNLIKELY ((feature = g_object_newv (type, 0, NULL)) == NULL)) {
GST_ERROR ("Can't create feature from type");
g_free (feature_name);
return FALSE;
}
feature->name = feature_name;
gst_plugin_feature_set_name (feature, feature_name);
if (G_UNLIKELY (!GST_IS_PLUGIN_FEATURE (feature))) {
GST_ERROR ("typename : '%s' is not a plugin feature", type_name);