--- gstreamer-org/gst/gstbin.c	2006-10-31 15:35:58.000000000 -0500
+++ gstreamer/gst/gstbin.c	2006-10-31 15:44:21.000000000 -0500
@@ -1848,13 +1848,15 @@
 {
   GstBin *bin;
   GstStateChangeReturn ret;
-  GstState current, next;
+  GstState current, next, pending;
   gboolean have_async;
   gboolean have_no_preroll;
   GstClockTime base_time;
   GstIterator *it;
   gboolean done;
 
+  pending = GST_STATE_PENDING (element);
+  
   /* we don't need to take the STATE_LOCK, it is already taken */
   current = (GstState) GST_STATE_TRANSITION_CURRENT (transition);
   next = (GstState) GST_STATE_TRANSITION_NEXT (transition);
@@ -1915,60 +1917,74 @@
         GstElement *child;
 
         child = GST_ELEMENT_CAST (data);
-
-        /* set base time on child */
+        GstState child_current;
+        
+        child_current = GST_STATE(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);
-
-        switch (ret) {
-          case GST_STATE_CHANGE_SUCCESS:
-            GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
-                "child '%s' changed state to %d(%s) successfully",
-                GST_ELEMENT_NAME (child), next,
-                gst_element_state_get_name (next));
-            break;
-          case GST_STATE_CHANGE_ASYNC:
-            GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
-                "child '%s' is changing state asynchronously",
-                GST_ELEMENT_NAME (child));
-            have_async = TRUE;
-            break;
-          case GST_STATE_CHANGE_FAILURE:
-            GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
-                "child '%s' failed to go to state %d(%s)",
-                GST_ELEMENT_NAME (child),
-                next, gst_element_state_get_name (next));
-            gst_object_unref (child);
-            goto done;
-          case GST_STATE_CHANGE_NO_PREROLL:
-            GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
-                "child '%s' changed state to %d(%s) successfully without preroll",
-                GST_ELEMENT_NAME (child), next,
-                gst_element_state_get_name (next));
-            have_no_preroll = TRUE;
-            break;
-          default:
-            g_assert_not_reached ();
-            break;
+  
+        if((pending > child_current && next > child_current) ||
+            (pending < child_current &&  next < child_current ))
+        {
+          /* set state now */
+          ret = gst_bin_element_set_state (bin, child, next);
+  
+            switch (ret) {
+              case GST_STATE_CHANGE_SUCCESS:
+                GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
+                    "child '%s' changed state to %d(%s) successfully",
+                    GST_ELEMENT_NAME (child), next,
+                    gst_element_state_get_name (next));
+                break;
+              case GST_STATE_CHANGE_ASYNC:
+                GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
+                    "child '%s' is changing state asynchronously",
+                    GST_ELEMENT_NAME (child));
+                have_async = TRUE;
+                break;
+              case GST_STATE_CHANGE_FAILURE:
+                GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
+                    "child '%s' failed to go to state %d(%s)",
+                    GST_ELEMENT_NAME (child),
+                    next, gst_element_state_get_name (next));
+                gst_object_unref (child);
+                goto done;
+              case GST_STATE_CHANGE_NO_PREROLL:
+                GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
+                    "child '%s' changed state to %d(%s) successfully without preroll",
+                    GST_ELEMENT_NAME (child), next,
+                    gst_element_state_get_name (next));
+                have_no_preroll = TRUE;
+                break;
+              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:
-        GST_CAT_DEBUG (GST_CAT_STATES, "iterator doing resync");
-        gst_iterator_resync (it);
-        goto restart;
-        break;
-      default:
-      case GST_ITERATOR_DONE:
-        GST_CAT_DEBUG (GST_CAT_STATES, "iterator done");
-        done = TRUE;
-        break;
+        case GST_ITERATOR_RESYNC:
+          GST_CAT_DEBUG (GST_CAT_STATES, "iterator doing resync");
+          gst_iterator_resync (it);
+          goto restart;
+          break;
+        default:
+        case GST_ITERATOR_DONE:
+          GST_CAT_DEBUG (GST_CAT_STATES, "iterator done");
+          done = TRUE;
+          break;
     }
   }
-
+  
+  
   ret = parent_class->change_state (element, transition);
   if (ret == GST_STATE_CHANGE_FAILURE)
     goto done;
