From e32e0a17ed884d65e8e88786b985127729d79839 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 26 Sep 2005 17:46:27 +0000 Subject: [PATCH] gst/gstbin.c: Make state change function use 3 queues again, we were adding elements in the wrong order. Original commit message from CVS: * gst/gstbin.c: (gst_bin_change_state): Make state change function use 3 queues again, we were adding elements in the wrong order. * gst/gstghostpad.c: (gst_ghost_pad_do_unlink): Some debug info, * gst/gstpad.c: (gst_pad_dispose): Added some debug info first. --- ChangeLog | 12 ++++++++++++ gst/gstbin.c | 27 +++++++++++++-------------- gst/gstghostpad.c | 2 ++ gst/gstpad.c | 4 ++-- 4 files changed, 29 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 867ba570dd..ed9cb407ea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2005-09-26 Wim Taymans + + * gst/gstbin.c: (gst_bin_change_state): + Make state change function use 3 queues again, we were + adding elements in the wrong order. + + * gst/gstghostpad.c: (gst_ghost_pad_do_unlink): + Some debug info, + + * gst/gstpad.c: (gst_pad_dispose): + Added some debug info first. + 2005-09-26 Tim-Philipp Müller * docs/design/draft-push-pull.txt: diff --git a/gst/gstbin.c b/gst/gstbin.c index ec231497b7..3d2ceff256 100644 --- a/gst/gstbin.c +++ b/gst/gstbin.c @@ -1128,12 +1128,6 @@ done: return ret; } -static void -append_child (gpointer child, GQueue * queue) -{ - g_queue_push_tail (queue, child); -} - /** * gst_bin_iterate_state_order: * @bin: #Gstbin to iterate on @@ -1290,12 +1284,8 @@ restart: * bin. We operate on the snapshot taken above. Applications * should serialize their add/remove and set_state. */ - /* now change state for semi sink elements first so add them in - * front of the other elements */ - g_queue_foreach (temp, (GFunc) append_child, semi_queue); - clear_queue (temp, FALSE); - - /* if we don't have real sinks, we continue with the other elements */ + /* if we don't have real sinks, we continue with the other elements, there + * has to be at least one element in the semi queue. */ if (g_queue_is_empty (elem_queue) && !g_queue_is_empty (semi_queue)) { GQueue *q = elem_queue; @@ -1315,6 +1305,7 @@ restart: qelement = g_queue_pop_head (elem_queue); /* we don't need any duplicates in the other queue anymore */ remove_all_from_queue (semi_queue, qelement, TRUE); + remove_all_from_queue (temp, qelement, TRUE); /* queue all elements connected to the sinkpads of this element */ GST_LOCK (qelement); @@ -1347,10 +1338,11 @@ restart: /* make sure we don't have duplicates */ remove_all_from_queue (semi_queue, peer_parent, TRUE); remove_all_from_queue (elem_queue, peer_parent, TRUE); + remove_all_from_queue (temp, peer_parent, TRUE); /* was reffed before pushing on the queue by the * gst_object_get_parent() call we used to get the element. */ - g_queue_push_head (elem_queue, peer_parent); + g_queue_push_tail (elem_queue, peer_parent); /* so that we don't unref it */ peer_parent = NULL; } else { @@ -1437,8 +1429,14 @@ restart: GST_DEBUG ("sinks and upstream elements exhausted"); non_sink = g_queue_pop_head (semi_queue); if (non_sink) { - GST_DEBUG ("found lefover non-sink %s", GST_OBJECT_NAME (non_sink)); + GST_DEBUG ("found lefover semi-sink %s", GST_OBJECT_NAME (non_sink)); g_queue_push_tail (elem_queue, non_sink); + } else { + non_sink = g_queue_pop_head (temp); + if (non_sink) { + GST_DEBUG ("found lefover non-sink %s", GST_OBJECT_NAME (non_sink)); + g_queue_push_tail (elem_queue, non_sink); + } } } } @@ -1462,6 +1460,7 @@ exit: * had an error. */ clear_queue (elem_queue, TRUE); clear_queue (semi_queue, TRUE); + clear_queue (temp, TRUE); g_queue_free (elem_queue); g_queue_free (semi_queue); g_queue_free (temp); diff --git a/gst/gstghostpad.c b/gst/gstghostpad.c index 0aae989d9f..fe80be52a0 100644 --- a/gst/gstghostpad.c +++ b/gst/gstghostpad.c @@ -604,6 +604,8 @@ gst_ghost_pad_do_unlink (GstPad * pad) g_return_if_fail (target != NULL); + GST_DEBUG_OBJECT (pad, "unlinking ghostpad"); + if (target->unlinkfunc) target->unlinkfunc (target); diff --git a/gst/gstpad.c b/gst/gstpad.c index 9f5263b11f..853b43aa46 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -312,11 +312,11 @@ gst_pad_dispose (GObject * object) /* FIXME: what about if g_object_dispose is explicitly called on the pad? Is that legal? otherwise we could assert GST_OBJECT_PARENT (pad) == NULL as well... */ - g_assert (GST_PAD_PEER (pad) == NULL); - GST_CAT_DEBUG (GST_CAT_REFCOUNTING, "dispose %s:%s", GST_DEBUG_PAD_NAME (pad)); + g_assert (GST_PAD_PEER (pad) == NULL); + /* clear the caps */ gst_caps_replace (&GST_PAD_CAPS (pad), NULL);