summaryrefslogtreecommitdiffstats
path: root/ext/gconf/gstswitchsink.c
diff options
context:
space:
mode:
authorJan Schmidt <thaytan@mad.scientist.com>2007-03-05 17:17:04 +0000
committerJan Schmidt <thaytan@mad.scientist.com>2007-03-05 17:17:04 +0000
commite87cd3fd7a0f1bea1f06b84494dec1d915b0282d (patch)
tree61860df7252b0e70b40f60d6e6cb4bc8b23d87de /ext/gconf/gstswitchsink.c
parent20f18abf7274698f6d0d155c49672474f95dc6cf (diff)
ext/gconf/gstswitchsink.c: Fix up the reference counting of the child elements.
Original commit message from CVS: * ext/gconf/gstswitchsink.c: (gst_switch_sink_dispose), (gst_switch_commit_new_kid): Fix up the reference counting of the child elements.
Diffstat (limited to 'ext/gconf/gstswitchsink.c')
-rw-r--r--ext/gconf/gstswitchsink.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/ext/gconf/gstswitchsink.c b/ext/gconf/gstswitchsink.c
index b5105acc..bd6715e2 100644
--- a/ext/gconf/gstswitchsink.c
+++ b/ext/gconf/gstswitchsink.c
@@ -100,10 +100,19 @@ static void
gst_switch_sink_dispose (GObject * object)
{
GstSwitchSink *sink = GST_SWITCH_SINK (object);
- GstElement **p_kid = &sink->kid;
+ GstElement **p_kid;
+ GST_OBJECT_LOCK (sink);
+ p_kid = &sink->new_kid;
gst_object_replace ((GstObject **) p_kid, NULL);
+ if (sink->new_kid) {
+ p_kid = &sink->kid;
+ gst_element_set_state (sink->kid, GST_STATE_NULL);
+ gst_object_replace ((GstObject **) p_kid, NULL);
+ }
+ GST_OBJECT_UNLOCK (sink);
+
GST_CALL_PARENT (G_OBJECT_CLASS, dispose, (object));
}
@@ -126,6 +135,8 @@ gst_switch_commit_new_kid (GstSwitchSink * sink)
if (new_kid == NULL) {
GST_DEBUG_OBJECT (sink, "Replacing kid with fakesink");
new_kid = gst_element_factory_make ("fakesink", "testsink");
+ /* Add a reference, as it would if the element came from sink->new_kid */
+ gst_object_ref (new_kid);
g_object_set (new_kid, "sync", TRUE, NULL);
is_fakesink = TRUE;
} else {
@@ -153,6 +164,7 @@ gst_switch_commit_new_kid (GstSwitchSink * sink)
GST_DEBUG_OBJECT (sink, "Removing old kid %" GST_PTR_FORMAT, old_kid);
gst_element_set_state (old_kid, GST_STATE_NULL);
gst_bin_remove (GST_BIN (sink), old_kid);
+ gst_object_unref (old_kid);
}
/* re-attach ghostpad */