summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2009-03-09 15:46:21 +0100
committerWim Taymans <wim.taymans@collabora.co.uk>2009-03-09 15:46:21 +0100
commit72533ecccc10a456377dda9f8cff7990dfe0cd98 (patch)
tree2f99f7e2e8cad0b577f22391ef03607319cd782f
parentf964c0fc383603df3cc2e43bdaa740a415e5d2a0 (diff)
decodebin2: only remove pads that were added
Flag pads that were added so that we can see if we need to remove them later or not.
-rw-r--r--gst/playback/gstdecodebin2.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/gst/playback/gstdecodebin2.c b/gst/playback/gstdecodebin2.c
index 4cb49bc69..de7acc8a2 100644
--- a/gst/playback/gstdecodebin2.c
+++ b/gst/playback/gstdecodebin2.c
@@ -301,6 +301,7 @@ struct _GstDecodePad
GstDecodeGroup *group;
gboolean blocked;
gboolean drained;
+ gboolean added;
};
G_DEFINE_TYPE (GstDecodePad, gst_decode_pad, GST_TYPE_GHOST_PAD);
@@ -2091,6 +2092,8 @@ gst_decode_group_expose (GstDecodeGroup * group)
if (!gst_element_add_pad (GST_ELEMENT (dbin), GST_PAD (dpad)))
goto name_problem;
+ dpad->added = TRUE;
+
/* 3. emit signal */
GST_DEBUG_OBJECT (dbin, "emitting new-decoded-pad");
g_signal_emit (G_OBJECT (dbin),
@@ -2154,8 +2157,13 @@ gst_decode_group_hide (GstDecodeGroup * group)
GROUP_MUTEX_LOCK (group);
/* Remove ghost pads */
- for (tmp = group->endpads; tmp; tmp = g_list_next (tmp))
- gst_element_remove_pad (GST_ELEMENT (group->dbin), GST_PAD (tmp->data));
+ for (tmp = group->endpads; tmp; tmp = g_list_next (tmp)) {
+ GstDecodePad *dpad = (GstDecodePad *) tmp->data;
+
+ if (dpad->added)
+ gst_element_remove_pad (GST_ELEMENT (group->dbin), GST_PAD (dpad));
+ dpad->added = FALSE;
+ }
group->exposed = FALSE;
@@ -2243,9 +2251,15 @@ gst_decode_group_free (GstDecodeGroup * group)
GROUP_MUTEX_LOCK (group);
/* remove exposed pads */
- if (group == group->dbin->activegroup)
- for (tmp = group->endpads; tmp; tmp = g_list_next (tmp))
- gst_element_remove_pad (GST_ELEMENT (group->dbin), GST_PAD (tmp->data));
+ if (group == group->dbin->activegroup) {
+ for (tmp = group->endpads; tmp; tmp = g_list_next (tmp)) {
+ GstDecodePad *dpad = (GstDecodePad *) tmp->data;
+
+ if (dpad->added)
+ gst_element_remove_pad (GST_ELEMENT (group->dbin), GST_PAD (dpad));
+ dpad->added = FALSE;
+ }
+ }
/* Clear all GstDecodePad */
for (tmp = group->endpads; tmp; tmp = g_list_next (tmp))