Index: gst/gstpad.c
===================================================================
RCS file: /cvs/gstreamer/gstreamer/gst/gstpad.c,v
retrieving revision 1.515
diff -u -r1.515 gstpad.c
--- gst/gstpad.c	12 Jun 2006 09:28:35 -0000	1.515
+++ gst/gstpad.c	29 Jun 2006 11:07:19 -0000
@@ -3039,34 +3039,6 @@
 
   return parent;
 }
-
-#if 0
-/**
- * gst_ghost_pad_save_thyself:
- * @pad: a ghost #GstPad to save.
- * @parent: the parent #xmlNodePtr to save the description in.
- *
- * Saves the ghost pad into an xml representation.
- *
- * Returns: the #xmlNodePtr representation of the pad.
- */
-xmlNodePtr
-gst_ghost_pad_save_thyself (GstPad * pad, xmlNodePtr parent)
-{
-  xmlNodePtr self;
-
-  g_return_val_if_fail (GST_IS_GHOST_PAD (pad), NULL);
-
-  self = xmlNewChild (parent, NULL, (xmlChar *) "ghostpad", NULL);
-  xmlNewChild (self, NULL, (xmlChar *) "name", (xmlChar *) GST_PAD_NAME (pad));
-  xmlNewChild (self, NULL, (xmlChar *) "parent",
-      (xmlChar *) GST_OBJECT_NAME (GST_PAD_PARENT (pad)));
-
-  /* FIXME FIXME FIXME! */
-
-  return self;
-}
-#endif /* 0 */
 #endif /* GST_DISABLE_LOADSAVE */
 
 /*
@@ -3084,7 +3056,9 @@
   GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad,
       "signal block taken on pad %s:%s", GST_DEBUG_PAD_NAME (pad));
 
-  /* need to grab extra ref for the callbacks */
+  if (GST_PAD_IS_FLUSHING (pad))
+    goto flushingnonref;
+
   gst_object_ref (pad);
 
   callback = pad->block_callback;
@@ -3121,6 +3095,11 @@
 
   return ret;
 
+ flushingnonref:
+  {
+    return GST_FLOW_WRONG_STATE;
+  }
+
 flushing:
   {
     gst_object_unref (pad);
@@ -3634,6 +3613,8 @@
   g_return_val_if_fail (event != NULL, FALSE);
   g_return_val_if_fail (GST_IS_EVENT (event), FALSE);
 
+  GST_LOG_OBJECT (pad, "event:%s", GST_EVENT_TYPE_NAME (event));
+
   GST_OBJECT_LOCK (pad);
   switch (GST_EVENT_TYPE (event)) {
     case GST_EVENT_FLUSH_START:
@@ -3646,10 +3627,16 @@
       break;
   }
 
+
   if (G_UNLIKELY (GST_PAD_IS_BLOCKED (pad))) {
     if (GST_EVENT_TYPE (event) == GST_EVENT_FLUSH_START) {
       GST_PAD_BLOCK_SIGNAL (pad);
-    }
+      goto flushed;
+    } else if (GST_PAD_IS_FLUSHING (pad) || (GST_EVENT_TYPE (event) == GST_EVENT_FLUSH_STOP)) {
+      goto flushed;
+    } else while (GST_PAD_IS_BLOCKED (pad))
+	     if (handle_pad_block (pad) != GST_FLOW_OK)
+	       goto flushed;
   }
 
   if (G_UNLIKELY (GST_PAD_DO_EVENT_SIGNALS (pad) > 0)) {
@@ -3660,6 +3647,7 @@
 
     GST_OBJECT_LOCK (pad);
   }
+
   peerpad = GST_PAD_PEER (pad);
   if (peerpad == NULL)
     goto not_linked;
@@ -3688,6 +3676,14 @@
     GST_OBJECT_UNLOCK (pad);
     return FALSE;
   }
+
+ flushed:
+  {
+    GST_DEBUG_OBJECT (pad, "Not forwarding event since we're flushing and blocking");
+    gst_event_unref (event);
+    GST_OBJECT_UNLOCK (pad);
+    return TRUE;
+  }
 }
 
 /**
