From 8694ff47b419d3ddd70ab4fa9a80d50802edf8cf Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 12 May 2005 13:18:14 +0000 Subject: [PATCH] gst/gstbin.c: Same fix as Ronald's but without the signal. Original commit message from CVS: * gst/gstbin.c: (gst_bin_remove_func), (gst_bin_get_state): Same fix as Ronald's but without the signal. --- ChangeLog | 5 +++++ gst/gstbin.c | 25 ++++++++----------------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 37145af..95850bc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-05-12 Wim Taymans + + * gst/gstbin.c: (gst_bin_remove_func), (gst_bin_get_state): + Same fix as Ronald's but without the signal. + 2005-05-12 Ronald S. Bultje * gst/gstutils.c: (gst_element_query_position): diff --git a/gst/gstbin.c b/gst/gstbin.c index c79f72b..52f7593 100644 --- a/gst/gstbin.c +++ b/gst/gstbin.c @@ -496,6 +496,14 @@ gst_bin_remove_func (GstBin * bin, GstElement * element) gst_element_set_bus (element, NULL); gst_element_set_scheduler (element, NULL); + /* unlock any waiters for the state change. It is possible that + * we are waiting for an ASYNC state change on this element. The + * element cannot be added to another bin yet as it is not yet + * unparented. */ + GST_STATE_LOCK (element); + GST_STATE_BROADCAST (element); + GST_STATE_UNLOCK (element); + /* we ref here because after the _unparent() the element can be disposed * and we still need it to fire a signal. */ gst_object_ref (GST_OBJECT_CAST (element)); @@ -760,19 +768,6 @@ gst_bin_iterate_sinks (GstBin * bin) return result; } -/* - * This function will be called if the child is removed from the bin - * while we try to get its state. We should abort the _get_state() - * immediately to prevent pointless further blocking. - */ -static void -cb_parent_unset (GstElement * child, GstElement * parent, gpointer data) -{ - GST_STATE_LOCK (child); - GST_STATE_BROADCAST (child); - GST_STATE_UNLOCK (child); -} - /* this functions loops over all children, as soon as one does * not return SUCCESS, we return that value. * @@ -799,16 +794,12 @@ restart: children_cookie = bin->children_cookie; while (children) { GstElement *child = GST_ELEMENT_CAST (children->data); - gulong sig; gst_object_ref (GST_OBJECT_CAST (child)); GST_UNLOCK (bin); /* ret is ASYNC if some child is still performing the state change */ - sig = g_signal_connect (child, "parent-unset", - G_CALLBACK (cb_parent_unset), NULL); ret = gst_element_get_state (child, NULL, NULL, timeout); - g_signal_handler_disconnect (child, sig); gst_object_unref (GST_OBJECT_CAST (child)); -- 2.7.4