mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-28 19:20:35 +00:00
pluginfeature: store pointer to plugin in addition to the plugin name
So we can reliably remove plugin features for a specific plugin later. https://bugzilla.gnome.org/show_bug.cgi?id=604094
This commit is contained in:
parent
d3d5b98c2f
commit
4926ce31c7
5 changed files with 25 additions and 4 deletions
|
@ -307,8 +307,12 @@ gst_element_register (GstPlugin * plugin, const gchar * name, guint rank,
|
|||
|
||||
if (plugin && plugin->desc.name) {
|
||||
GST_PLUGIN_FEATURE_CAST (factory)->plugin_name = plugin->desc.name;
|
||||
GST_PLUGIN_FEATURE_CAST (factory)->plugin = plugin;
|
||||
g_object_add_weak_pointer ((GObject *) plugin,
|
||||
(gpointer *) & GST_PLUGIN_FEATURE_CAST (factory)->plugin);
|
||||
} else {
|
||||
GST_PLUGIN_FEATURE_CAST (factory)->plugin_name = "NULL";
|
||||
GST_PLUGIN_FEATURE_CAST (factory)->plugin = NULL;
|
||||
}
|
||||
gst_plugin_feature_set_rank (GST_PLUGIN_FEATURE_CAST (factory), rank);
|
||||
GST_PLUGIN_FEATURE_CAST (factory)->loaded = TRUE;
|
||||
|
|
|
@ -67,6 +67,11 @@ gst_plugin_feature_finalize (GObject * object)
|
|||
GST_PLUGIN_FEATURE_NAME (feature));
|
||||
g_free (feature->name);
|
||||
|
||||
if (feature->plugin != NULL) {
|
||||
g_object_remove_weak_pointer ((GObject *) feature->plugin,
|
||||
(gpointer *) & feature->plugin);
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (gst_plugin_feature_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
|
|
|
@ -84,9 +84,10 @@ struct _GstPluginFeature {
|
|||
guint rank;
|
||||
|
||||
const gchar *plugin_name;
|
||||
GstPlugin *plugin; /* weak ref */
|
||||
|
||||
/*< private >*/
|
||||
gpointer _gst_reserved[GST_PADDING];
|
||||
gpointer _gst_reserved[GST_PADDING - 1];
|
||||
};
|
||||
|
||||
struct _GstPluginFeatureClass {
|
||||
|
|
|
@ -527,15 +527,18 @@ fail:
|
|||
*/
|
||||
static gboolean
|
||||
gst_registry_chunks_load_feature (GstRegistry * registry, gchar ** in,
|
||||
gchar * end, const gchar * plugin_name)
|
||||
gchar * end, GstPlugin * plugin)
|
||||
{
|
||||
GstRegistryChunkPluginFeature *pf = NULL;
|
||||
GstPluginFeature *feature = NULL;
|
||||
const gchar *const_str, *type_name;
|
||||
const gchar *plugin_name;
|
||||
gchar *str, *feature_name;
|
||||
GType type;
|
||||
guint i;
|
||||
|
||||
plugin_name = plugin->desc.name;
|
||||
|
||||
/* unpack plugin feature strings */
|
||||
unpack_string_nocopy (*in, type_name, end, fail);
|
||||
|
||||
|
@ -681,9 +684,13 @@ gst_registry_chunks_load_feature (GstRegistry * registry, gchar ** in,
|
|||
feature->rank = pf->rank;
|
||||
|
||||
feature->plugin_name = plugin_name;
|
||||
feature->plugin = plugin;
|
||||
g_object_add_weak_pointer ((GObject *) plugin,
|
||||
(gpointer *) & feature->plugin);
|
||||
|
||||
gst_registry_add_feature (registry, feature);
|
||||
GST_DEBUG ("Added feature %s", feature->name);
|
||||
GST_DEBUG ("Added feature %s, plugin %p %s", feature->name, plugin,
|
||||
plugin_name);
|
||||
|
||||
return TRUE;
|
||||
|
||||
|
@ -836,7 +843,7 @@ _priv_gst_registry_chunks_load_plugin (GstRegistry * registry, gchar ** in,
|
|||
/* Load plugin features */
|
||||
for (i = 0; i < n; i++) {
|
||||
if (G_UNLIKELY (!gst_registry_chunks_load_feature (registry, in, end,
|
||||
plugin->desc.name))) {
|
||||
plugin))) {
|
||||
GST_ERROR ("Error while loading binary feature for plugin '%s'",
|
||||
GST_STR_NULL (plugin->desc.name));
|
||||
gst_registry_remove_plugin (registry, plugin);
|
||||
|
|
|
@ -99,8 +99,12 @@ gst_type_find_register (GstPlugin * plugin, const gchar * name, guint rank,
|
|||
factory->user_data_notify = data_notify;
|
||||
if (plugin && plugin->desc.name) {
|
||||
GST_PLUGIN_FEATURE_CAST (factory)->plugin_name = plugin->desc.name; /* interned string */
|
||||
GST_PLUGIN_FEATURE_CAST (factory)->plugin = plugin;
|
||||
g_object_add_weak_pointer ((GObject *) plugin,
|
||||
(gpointer *) & GST_PLUGIN_FEATURE_CAST (factory)->plugin);
|
||||
} else {
|
||||
GST_PLUGIN_FEATURE_CAST (factory)->plugin_name = "NULL";
|
||||
GST_PLUGIN_FEATURE_CAST (factory)->plugin = NULL;
|
||||
}
|
||||
GST_PLUGIN_FEATURE_CAST (factory)->loaded = TRUE;
|
||||
|
||||
|
|
Loading…
Reference in a new issue