commit 19c5b2736fb70c253c1fb06c36dc59f76c3e16d5
Author: Wim Taymans <wim.taymans@collabora.co.uk>
Date:   Tue Jan 26 12:43:09 2010 +0100

    multiqueue: handle UNEXPECTED flowreturn better
    
    When we receive an UNEXPECTED flowreturn from downstream, we must not shutdown
    the pushing thread because upstream will at some point push an EOS that we still
    need to push further downstream.
    
    To achieve this, convert the UNEXPECTED return value to OK. Add a fixme so that
    we implement the right logic to propagate the flowreturn upstream at some point.
    
    Also clean up the unit test a little.
    
    Fixes #608136

diff --git a/plugins/elements/gstmultiqueue.c b/plugins/elements/gstmultiqueue.c
index 0b8439c..30f1165 100644
--- a/plugins/elements/gstmultiqueue.c
+++ b/plugins/elements/gstmultiqueue.c
@@ -917,6 +917,13 @@ gst_single_queue_push_one (GstMultiQueue * mq, GstSingleQueue * sq,
       gst_pad_set_caps (sq->srcpad, caps);
 
     result = gst_pad_push (sq->srcpad, buffer);
+
+    if (result == GST_FLOW_UNEXPECTED) {
+      GST_LOG_OBJECT (mq, "got UNEXPECTED from downstream");
+      /* FIXME, dequeue items until we see EOS or NEWSEGMENT. If the queue is
+       * empty, set a flag so that we pass unexpected upstream. */
+      result = GST_FLOW_OK;
+    }
   } else if (GST_IS_EVENT (object)) {
     GstEvent *event;
 
diff --git a/tests/check/elements/multiqueue.c b/tests/check/elements/multiqueue.c
index 1c7a418..c956d25 100644
--- a/tests/check/elements/multiqueue.c
+++ b/tests/check/elements/multiqueue.c
@@ -479,13 +479,13 @@ run_output_order_test (gint n_linked)
 
   /* Wait while the buffers are processed */
   g_mutex_lock (mutex);
-  while (eos_seen < 5) {
+  while (eos_seen < NPADS) {
     g_cond_wait (cond, mutex);
   }
   g_mutex_unlock (mutex);
 
   /* Clean up */
-  for (i = 0; i < 5; i++) {
+  for (i = 0; i < NPADS; i++) {
     GstPad *mq_input = gst_pad_get_peer (inputpads[i]);
 
     gst_pad_unlink (inputpads[i], mq_input);
