glmixerbin: implement proper dynamic pad removal

https://bugzilla.gnome.org/show_bug.cgi?id=750881
This commit is contained in:
Matthew Waters 2015-06-13 18:43:04 +10:00 committed by Tim-Philipp Müller
parent ccc410e73c
commit 8c36e5193e

View file

@ -47,19 +47,17 @@ _free_input_chain (struct input_chain *chain)
if (!chain) if (!chain)
return; return;
if (chain->ghost_pad)
gst_object_unref (chain->ghost_pad);
chain->ghost_pad = NULL; chain->ghost_pad = NULL;
if (chain->upload) { if (chain->upload) {
gst_element_set_state (chain->upload, GST_STATE_NULL);
gst_bin_remove (GST_BIN (chain->self), chain->upload); gst_bin_remove (GST_BIN (chain->self), chain->upload);
gst_object_unref (chain->upload);
chain->upload = NULL; chain->upload = NULL;
} }
if (chain->in_convert) { if (chain->in_convert) {
gst_element_set_state (chain->in_convert, GST_STATE_NULL);
gst_bin_remove (GST_BIN (chain->self), chain->in_convert); gst_bin_remove (GST_BIN (chain->self), chain->in_convert);
gst_object_unref (chain->in_convert);
chain->in_convert = NULL; chain->in_convert = NULL;
} }
@ -449,21 +447,25 @@ gst_gl_mixer_bin_release_pad (GstElement * element, GstPad * pad)
{ {
GstGLMixerBin *self = GST_GL_MIXER_BIN (element); GstGLMixerBin *self = GST_GL_MIXER_BIN (element);
GList *l = self->priv->input_chains; GList *l = self->priv->input_chains;
gboolean released = FALSE;
GST_OBJECT_LOCK (element); GST_OBJECT_LOCK (element);
while (l) { while (l) {
struct input_chain *chain = l->data; struct input_chain *chain = l->data;
if (chain->mixer_pad == pad) { if (GST_PAD (chain->ghost_pad) == pad) {
_free_input_chain (chain);
self->priv->input_chains = self->priv->input_chains =
g_list_remove_link (self->priv->input_chains, l); g_list_remove_link (self->priv->input_chains, l);
GST_OBJECT_UNLOCK (element);
_free_input_chain (chain);
gst_element_remove_pad (element, pad);
released = TRUE;
break; break;
} }
l = l->next; l = l->next;
} }
GST_OBJECT_UNLOCK (element); if (!released)
GST_OBJECT_UNLOCK (element);
gst_element_remove_pad (element, pad);
} }
static GstStateChangeReturn static GstStateChangeReturn