commit 31f65f2c262164c540a58b4439b1a2c4f4be7218
Author: Duncan Palmer <dpalmer@digisoft.tv>
Date:   Mon Feb 16 09:25:03 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 00e5132..d009861 100644
--- a/gst/playback/gstdecodebin2.c
+++ b/gst/playback/gstdecodebin2.c
@@ -285,7 +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);
+    GstElement * multiqueue, gboolean use_buffering, gboolean preroll,
+    gboolean seekable);
 
 static gboolean gst_decode_bin_autoplug_continue (GstElement * element,
     GstPad * pad, GstCaps * caps);
@@ -2864,6 +2865,7 @@ static void
 no_more_pads_cb (GstElement * element, GstDecodeChain * chain)
 {
   GstDecodeGroup *group = NULL;
+  gboolean use_buffering;
 
   GST_LOG_OBJECT (element, "got no more pads");
 
@@ -2901,12 +2903,14 @@ no_more_pads_cb (GstElement * element, GstDecodeChain * chain)
   GST_DEBUG_OBJECT (element, "Setting group %p to complete", group);
 
   group->no_more_pads = TRUE;
+  /* get the current config from the multiqueue */
+  g_object_get (group->multiqueue, "use-buffering", &use_buffering, NULL);
   /* this group has prerolled enough to not need more pads,
    * we can probably set its buffering state to playing now */
   GST_DEBUG_OBJECT (group->dbin, "Setting group %p multiqueue to "
       "'playing' buffering mode", group);
-  decodebin_set_queue_size (group->dbin, group->multiqueue, FALSE,
-      (group->parent ? group->parent->seekable : TRUE));
+  decodebin_set_queue_size (group->dbin, group->multiqueue, use_buffering,
+      FALSE, (group->parent ? group->parent->seekable : TRUE));
   CHAIN_MUTEX_UNLOCK (chain);
 
   EXPOSE_LOCK (chain->dbin);
@@ -3315,6 +3319,7 @@ static void
 multi_queue_overrun_cb (GstElement * queue, GstDecodeGroup * group)
 {
   GstDecodeBin *dbin;
+  gboolean use_buffering;
 
   dbin = group->dbin;
 
@@ -3322,12 +3327,14 @@ multi_queue_overrun_cb (GstElement * queue, GstDecodeGroup * group)
       queue);
 
   group->overrun = TRUE;
+  /* get the current config from the multiqueue */
+  g_object_get (group->multiqueue, "use-buffering", &use_buffering, NULL);
   /* this group has prerolled enough to not need more pads,
    * we can probably set its buffering state to playing now */
   GST_DEBUG_OBJECT (group->dbin, "Setting group %p multiqueue to "
       "'playing' buffering mode", group);
-  decodebin_set_queue_size (group->dbin, group->multiqueue, FALSE,
-      (group->parent ? group->parent->seekable : TRUE));
+  decodebin_set_queue_size (group->dbin, group->multiqueue, use_buffering,
+      FALSE, (group->parent ? group->parent->seekable : TRUE));
 
   /* FIXME: We should make sure that everything gets exposed now
    * even if child chains are not complete because the will never
@@ -3484,14 +3491,10 @@ gst_decode_chain_start_free_hidden_groups_thread (GstDecodeChain * chain)
  * playing or prerolling. */
 static void
 decodebin_set_queue_size (GstDecodeBin * dbin, GstElement * multiqueue,
-    gboolean preroll, gboolean seekable)
+    gboolean use_buffering, gboolean preroll, gboolean seekable)
 {
   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);
 
@@ -3567,7 +3570,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);
 
   group->overrunsig = g_signal_connect (mq, "overrun",
       G_CALLBACK (multi_queue_overrun_cb), group);
@@ -3975,6 +3978,9 @@ 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));
+
   if (ret) {
     /* all chains are buffering already, no need to do it here */
     g_object_set (group->multiqueue, "use-buffering", FALSE, NULL);
@@ -3983,8 +3989,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));
 
   GST_DEBUG_OBJECT (group->dbin, "Setting %s buffering to %d",
       GST_ELEMENT_NAME (group->multiqueue), !ret);
