--- gstreamer-org/gst/gstbin.c	2006-11-06 13:03:30.000000000 -0500
+++ gstreamer/gst/gstbin.c	2006-11-06 13:06:15.000000000 -0500
@@ -1849,7 +1849,7 @@
 {
   GstBin *bin;
   GstStateChangeReturn ret;
-  GstState current, next;
+  GstState current, next, pending;
   gboolean have_async;
   gboolean have_no_preroll;
   GstClockTime base_time;
@@ -1857,6 +1857,7 @@
   gboolean done;
 
   /* we don't need to take the STATE_LOCK, it is already taken */
+  pending = (GstState)  GST_STATE_PENDING (element);
   current = (GstState) GST_STATE_TRANSITION_CURRENT (transition);
   next = (GstState) GST_STATE_TRANSITION_NEXT (transition);
 
@@ -1916,14 +1917,25 @@
         GstElement *child;
 
         child = GST_ELEMENT_CAST (data);
+        GstState child_current, child_pending;
+
+        child_current = GST_STATE(child);
+        child_pending = GST_STATE_PENDING(child);
 
         /* set base time on child */
         gst_element_set_base_time (child, base_time);
 
-        /* set state now */
-        ret = gst_bin_element_set_state (bin, child, next);
+        if((child_pending == GST_STATE_VOID_PENDING &&
+            ((pending > child_current && next > child_current) ||
+             (pending < child_current && next < child_current ))) ||
+           (child_pending != GST_STATE_VOID_PENDING &&
+            ((pending > child_current && next > child_pending) ||
+             (pending < child_current && next < child_pending ))))
+        {
+          /* set state now */
+          ret = gst_bin_element_set_state (bin, child, next);
 
-        switch (ret) {
+          switch (ret) {
           case GST_STATE_CHANGE_SUCCESS:
             GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
                 "child '%s' changed state to %d(%s) successfully",
@@ -1953,8 +1965,15 @@
           default:
             g_assert_not_reached ();
             break;
+          }
+          gst_object_unref (child);
+        }
+        else
+        {
+          GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
+            "child %s, is skipping transition from %s to  %s, since bin pending is %s", GST_ELEMENT_NAME(child), gst_element_state_get_name (child_current),
+             gst_element_state_get_name (next), gst_element_state_get_name (pending));
         }
-        gst_object_unref (child);
         break;
       }
       case GST_ITERATOR_RESYNC:
