gst/gstbin.c: Make state change function use 3 queues again, we were adding elements...
authorWim Taymans <wim.taymans@gmail.com>
Mon, 26 Sep 2005 17:46:27 +0000 (17:46 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Mon, 26 Sep 2005 17:46:27 +0000 (17:46 +0000)
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
gst/gstbin.c
gst/gstghostpad.c
gst/gstpad.c

index 867ba57..ed9cb40 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2005-09-26  Wim Taymans  <wim@fluendo.com>
+
+       * 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  <tim at centricular dot net>
 
        * docs/design/draft-push-pull.txt:
index ec23149..3d2ceff 100644 (file)
@@ -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);
index 0aae989..fe80be5 100644 (file)
@@ -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);
 
index 9f5263b..853b43a 100644 (file)
@@ -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);