Index: gst/gstbin.c
===================================================================
RCS file: /cvs/gstreamer/gstreamer/gst/gstbin.c,v
retrieving revision 1.381
diff -u -r1.381 gstbin.c
--- gst/gstbin.c	31 Jul 2008 15:20:29 -0000	1.381
+++ gst/gstbin.c	1 Aug 2008 23:34:51 -0000
@@ -2546,8 +2546,6 @@
   target = GST_STATE_TARGET (bin);
   pending = GST_STATE_PENDING (bin) = target;
 
-  amessage = gst_message_new_async_done (GST_OBJECT_CAST (bin));
-
   old_state = GST_STATE (bin);
   /* this is the state we should go to next */
   old_next = GST_STATE_NEXT (bin);
@@ -2608,6 +2606,8 @@
     GST_DEBUG_OBJECT (bin, "posting state change message");
     gst_element_post_message (GST_ELEMENT_CAST (bin), smessage);
   }
+
+  amessage = gst_message_new_async_done (GST_OBJECT_CAST (bin));
   if (amessage) {
     /* post our combined ASYNC_DONE when all is ASYNC_DONE. */
     GST_DEBUG_OBJECT (bin, "posting ASYNC_DONE to parent");
@@ -2633,6 +2633,13 @@
 was_busy:
   {
     GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, bin, "state change busy");
+    amessage = gst_message_new_async_done (GST_OBJECT_CAST (bin));
+
+    GST_OBJECT_UNLOCK (bin);
+    /* post our combined ASYNC_DONE when all is ASYNC_DONE. */
+    GST_DEBUG_OBJECT (bin, "posting ASYNC_DONE to parent");
+    gst_element_post_message (GST_ELEMENT_CAST (bin), amessage);
+    GST_OBJECT_LOCK (bin);
     return;
   }
 nothing_pending:
@@ -2890,6 +2897,9 @@
         GST_DEBUG_OBJECT (bin, "async elements commited");
         bin_handle_async_done (bin, GST_STATE_CHANGE_SUCCESS);
       }
+      else {
+        GST_DEBUG_OBJECT (bin, "Some children still async. Not posting.");
+      }
       GST_OBJECT_UNLOCK (bin);
       break;
 
