commit 61746e9df1f2446ae51aa48cb6545972ee75dcc4
Author: Duncan Palmer <dpalmer@digisoft.tv>
Date:   Tue Feb 10 16:42:27 2015 +1000

    DDTWO-1287 decodebin2 Set multiqueue sizes before use-buffering.
    
    This fixes a race where the use-buffering property on a multiqueue was
    set before the queue depth was changed from it's high preroll limits to
    lower playback limits. This resulted in buffering messages being emitted
    by the multiqueue in the short window between use-buffering being
    set and the queue depth being reset.

diff --git a/gst/playback/gstdecodebin2.c b/gst/playback/gstdecodebin2.c
index 01984fe..a367982 100644
--- a/gst/playback/gstdecodebin2.c
+++ b/gst/playback/gstdecodebin2.c
@@ -285,8 +285,8 @@ static void type_found (GstElement * typefind, guint probability,
     GstCaps * caps, GstDecodeBin * decode_bin);
 
 static void decodebin_set_queue_size (GstDecodeBin * dbin,
-    GstElement * multiqueue, gboolean preroll, gboolean seekable,
-    gboolean adaptive_streaming);
+    GstElement * multiqueue, gboolean use_buffering, gboolean preroll,
+    gboolean seekable, gboolean adaptive_streaming);
 
 static gboolean gst_decode_bin_autoplug_continue (GstElement * element,
     GstPad * pad, GstCaps * caps);
@@ -3178,14 +3178,11 @@ gst_decode_group_hide (GstDecodeGroup * group)
  * playing or prerolling. */
 static void
 decodebin_set_queue_size (GstDecodeBin * dbin, GstElement * multiqueue,
-    gboolean preroll, gboolean seekable, gboolean adaptive_streaming)
+    gboolean use_buffering, gboolean preroll, gboolean seekable,
+    gboolean adaptive_streaming)
 {
   guint max_bytes, max_buffers;
   guint64 max_time;
-  gboolean use_buffering;
-
-  /* get the current config from the multiqueue */
-  g_object_get (multiqueue, "use-buffering", &use_buffering, NULL);
 
   GST_DEBUG_OBJECT (multiqueue, "use buffering %d", use_buffering);
 
@@ -3272,7 +3269,7 @@ gst_decode_group_new (GstDecodeBin * dbin, GstDecodeChain * parent)
       gst_object_unref (pad);
     }
   }
-  decodebin_set_queue_size (dbin, mq, TRUE, seekable,
+  decodebin_set_queue_size (dbin, mq, FALSE, TRUE, seekable,
       (parent ? parent->adaptive_demuxer : FALSE));
 
   group->overrunsig = g_signal_connect (mq, "overrun",
@@ -3666,6 +3663,7 @@ gst_decode_group_reset_buffering (GstDecodeGroup * group)
 {
   GList *l;
   gboolean ret = TRUE;
+  gboolean use_buffering;
 
   GST_DEBUG_OBJECT (group->dbin, "Group reset buffering %p %s", group,
       GST_ELEMENT_NAME (group->multiqueue));
@@ -3679,6 +3677,10 @@ gst_decode_group_reset_buffering (GstDecodeGroup * group)
     CHAIN_MUTEX_UNLOCK (chain);
   }
 
+  decodebin_set_queue_size (group->dbin, group->multiqueue, !ret,
+      FALSE, (group->parent ? group->parent->seekable : TRUE),
+      (group->parent ? group->parent->adaptive_demuxer : FALSE));
+
   if (ret) {
     /* all chains are buffering already, no need to do it here */
     g_object_set (group->multiqueue, "use-buffering", FALSE, NULL);
@@ -3687,9 +3689,6 @@ gst_decode_group_reset_buffering (GstDecodeGroup * group)
         "low-percent", group->dbin->low_percent,
         "high-percent", group->dbin->high_percent, NULL);
   }
-  decodebin_set_queue_size (group->dbin, group->multiqueue, FALSE,
-      (group->parent ? group->parent->seekable : TRUE),
-      (group->parent ? group->parent->adaptive_demuxer : FALSE));
 
   GST_DEBUG_OBJECT (group->dbin, "Setting %s buffering to %d",
       GST_ELEMENT_NAME (group->multiqueue), !ret);
