mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-18 13:25:56 +00:00
nlecomposition: ensure elements pending to be added are not leaked
When nlecomposition is finalized with pending add action or io, associated elements are not unreffed as they should since caller gives us the reference when calling gst_bin_add causing them to be leaked. So to make sure we don't leak a reference on element when adding one to the bin, each stage (action and pending_io) hold a reference on element and release it when stage is done. https://bugzilla.gnome.org/show_bug.cgi?id=766455
This commit is contained in:
parent
dd5bf558c2
commit
62456af2a2
1 changed files with 15 additions and 6 deletions
|
@ -584,7 +584,9 @@ _process_pending_entries (NleComposition * comp)
|
|||
|
||||
_nle_composition_remove_object (comp, object);
|
||||
} else {
|
||||
_nle_composition_add_object (comp, object);
|
||||
/* take a new ref on object as the current one will be released when
|
||||
* object is removed from pending_io */
|
||||
_nle_composition_add_object (comp, gst_object_ref (object));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -688,7 +690,7 @@ _remove_object_func (NleComposition * comp, ChildIOData * childio)
|
|||
return;
|
||||
}
|
||||
|
||||
g_hash_table_add (priv->pending_io, object);
|
||||
g_hash_table_add (priv->pending_io, gst_object_ref (object));
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -738,7 +740,9 @@ _add_object_func (NleComposition * comp, ChildIOData * childio)
|
|||
return;
|
||||
}
|
||||
|
||||
g_hash_table_add (priv->pending_io, object);
|
||||
/* current reference is hold by the action and will be released with it,
|
||||
* so take a new one */
|
||||
g_hash_table_add (priv->pending_io, gst_object_ref (object));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -765,8 +769,12 @@ _free_action (gpointer udata, Action * action)
|
|||
|
||||
gst_event_unref (seekd->event);
|
||||
g_slice_free (SeekData, seekd);
|
||||
} else if (ACTION_CALLBACK (action) == _remove_object_func ||
|
||||
ACTION_CALLBACK (action) == _add_object_func) {
|
||||
} else if (ACTION_CALLBACK (action) == _add_object_func) {
|
||||
ChildIOData *iodata = (ChildIOData *) udata;
|
||||
|
||||
gst_object_unref (iodata->object);
|
||||
g_slice_free (ChildIOData, iodata);
|
||||
} else if (ACTION_CALLBACK (action) == _remove_object_func) {
|
||||
g_slice_free (ChildIOData, udata);
|
||||
} else if (ACTION_CALLBACK (action) == _update_pipeline_func ||
|
||||
ACTION_CALLBACK (action) == _commit_func ||
|
||||
|
@ -974,7 +982,8 @@ nle_composition_init (NleComposition * comp)
|
|||
g_mutex_init (&priv->actions_lock);
|
||||
g_cond_init (&priv->actions_cond);
|
||||
|
||||
priv->pending_io = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
priv->pending_io = g_hash_table_new_full (g_direct_hash, g_direct_equal,
|
||||
gst_object_unref, NULL);
|
||||
|
||||
comp->priv = priv;
|
||||
|
||||
|
|
Loading…
Reference in a new issue