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.
This commit is contained in:
Jan Schmidt 2007-03-05 17:17:04 +00:00
parent 20f18abf72
commit e87cd3fd7a
2 changed files with 19 additions and 1 deletions

View file

@ -1,3 +1,9 @@
2007-03-05 Jan Schmidt <thaytan@mad.scientist.com>
* ext/gconf/gstswitchsink.c: (gst_switch_sink_dispose),
(gst_switch_commit_new_kid):
Fix up the reference counting of the child elements.
2007-03-05 Wim Taymans <wim@fluendo.com> 2007-03-05 Wim Taymans <wim@fluendo.com>
* gst/rtp/gstrtpmp4gpay.c: (gst_rtp_mp4g_pay_setcaps): * gst/rtp/gstrtpmp4gpay.c: (gst_rtp_mp4g_pay_setcaps):

View file

@ -100,10 +100,19 @@ static void
gst_switch_sink_dispose (GObject * object) gst_switch_sink_dispose (GObject * object)
{ {
GstSwitchSink *sink = GST_SWITCH_SINK (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); 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)); GST_CALL_PARENT (G_OBJECT_CLASS, dispose, (object));
} }
@ -126,6 +135,8 @@ gst_switch_commit_new_kid (GstSwitchSink * sink)
if (new_kid == NULL) { if (new_kid == NULL) {
GST_DEBUG_OBJECT (sink, "Replacing kid with fakesink"); GST_DEBUG_OBJECT (sink, "Replacing kid with fakesink");
new_kid = gst_element_factory_make ("fakesink", "testsink"); 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); g_object_set (new_kid, "sync", TRUE, NULL);
is_fakesink = TRUE; is_fakesink = TRUE;
} else { } 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_DEBUG_OBJECT (sink, "Removing old kid %" GST_PTR_FORMAT, old_kid);
gst_element_set_state (old_kid, GST_STATE_NULL); gst_element_set_state (old_kid, GST_STATE_NULL);
gst_bin_remove (GST_BIN (sink), old_kid); gst_bin_remove (GST_BIN (sink), old_kid);
gst_object_unref (old_kid);
} }
/* re-attach ghostpad */ /* re-attach ghostpad */