Index: gst/gstpipeline.c
===================================================================
RCS file: /cvs/gstreamer/gstreamer/gst/gstpipeline.c,v
retrieving revision 1.138
diff -u -r1.138 gstpipeline.c
--- gst/gstpipeline.c	15 Sep 2006 08:43:44 -0000	1.138
+++ gst/gstpipeline.c	2 Dec 2006 13:49:05 -0000
@@ -491,6 +491,22 @@
 
   switch (transition) {
     case GST_STATE_CHANGE_NULL_TO_READY:
+      if (result == GST_STATE_CHANGE_FAILURE) {
+        /* When we fail to go to READY state, handle it as if we had 
+         * returned to the NULL state and auto-flush the bus */
+        GST_OBJECT_LOCK (element);
+        if (element->bus) {
+          if (pipeline->priv->auto_flush_bus) {
+            GST_INFO_OBJECT (element, 
+                "Setting bus to flushing after failed state change");
+            gst_bus_set_flushing (element->bus, TRUE);
+          } else {
+            GST_INFO_OBJECT (element, 
+                "not flushing bus, auto-flushing disabled");
+          }
+        }
+        GST_OBJECT_UNLOCK (element);
+      }
       break;
     case GST_STATE_CHANGE_READY_TO_PAUSED:
     {
