---
 plugins/elements/gstqueue.c |   52 +++++++++++++++++++++++++++++++++++++++++++-
 plugins/elements/gstqueue.h |    4 +++
 2 files changed, 55 insertions(+), 1 deletion(-)

--- gstreamer.orig/plugins/elements/gstqueue.c
+++ gstreamer/plugins/elements/gstqueue.c
@@ -118,7 +118,8 @@
   ARG_MIN_THRESHOLD_BUFFERS,
   ARG_MIN_THRESHOLD_BYTES,
   ARG_MIN_THRESHOLD_TIME,
-  ARG_LEAKY
+  ARG_LEAKY,
+  ARG_LOAD_BURST
       /* FILL ME */
 };
 
@@ -126,6 +127,7 @@
 #define DEFAULT_MAX_SIZE_BUFFERS  200   /* 200 buffers */
 #define DEFAULT_MAX_SIZE_BYTES    (10 * 1024 * 1024)    /* 10 MB       */
 #define DEFAULT_MAX_SIZE_TIME     GST_SECOND    /* 1 second    */
+#define DEFAULT_LOAD_BURST          FALSE
 
 #define GST_QUEUE_MUTEX_LOCK(q) G_STMT_START {                          \
   g_mutex_lock (q->qlock);                                              \
@@ -171,6 +173,22 @@
   g_cond_signal (q->item_add);                                          \
 } G_STMT_END
 
+#define GST_QUEUE_WAIT_BURST(q) {                                       \
+  if (queue->burst && queue->burst_wait) {                              \
+    STATUS (q, q->sinkpad, "wait BURST");                               \
+    while (queue->burst_wait)                                           \
+      g_cond_wait (q->burst_cond, q->qlock);                            \
+  }                                                                     \
+}
+
+#define GST_QUEUE_SIGNAL_BURST(q) {                                     \
+  if (queue->burst) {                                                   \
+    queue->burst_wait = FALSE;                                          \
+    STATUS (q, q->sinkpad, "signal BURST");                             \
+    g_cond_signal (queue->burst_cond);                                  \
+  }                                                                     \
+}
+
 #define _do_init(bla) \
     GST_DEBUG_CATEGORY_INIT (queue_debug, "queue", 0, "queue element"); \
     GST_DEBUG_CATEGORY_INIT (queue_dataflow, "queue_dataflow", 0, \
@@ -354,6 +372,11 @@
           GST_TYPE_QUEUE_LEAKY, GST_QUEUE_NO_LEAK,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+  g_object_class_install_property (gobject_class, ARG_LOAD_BURST,
+      g_param_spec_boolean ("load-burst", "Load Burst",
+          "Load the queue to max in bursts", DEFAULT_LOAD_BURST,
+          G_PARAM_READWRITE));
+
   /* set several parent class virtual functions */
   gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_queue_finalize);
 
@@ -411,6 +434,10 @@
   queue->item_del = g_cond_new ();
   queue->queue = g_queue_new ();
 
+  queue->burst = DEFAULT_LOAD_BURST;
+  queue->burst_wait = FALSE;
+  queue->burst_cond = g_cond_new ();
+
   GST_DEBUG_OBJECT (queue,
       "initialized queue's not_empty & not_full conditions");
 }
@@ -432,6 +459,7 @@
   g_mutex_free (queue->qlock);
   g_cond_free (queue->item_add);
   g_cond_free (queue->item_del);
+  g_cond_free (queue->burst_cond);
 
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
@@ -729,6 +757,9 @@
 
   queue = GST_QUEUE (GST_OBJECT_PARENT (pad));
 
+  /* unlock the burst on an event */
+  GST_QUEUE_SIGNAL_BURST (queue);
+
   switch (GST_EVENT_TYPE (event)) {
     case GST_EVENT_FLUSH_START:
     {
@@ -884,6 +915,10 @@
     g_signal_emit (G_OBJECT (queue), gst_queue_signals[SIGNAL_OVERRUN], 0);
     GST_QUEUE_MUTEX_LOCK_CHECK (queue, out_flushing);
 
+    /* mark that we should wait until the queue is at minimum */
+    if (queue->burst)
+      queue->burst_wait = TRUE;
+
     /* we recheck, the signal could have changed the thresholds */
     if (!gst_queue_is_filled (queue))
       break;
@@ -937,6 +972,8 @@
     queue->tail_needs_discont = FALSE;
   }
 
+  GST_QUEUE_WAIT_BURST (queue);
+
   /* put buffer in queue now */
   gst_queue_locked_enqueue (queue, buffer);
   GST_QUEUE_MUTEX_UNLOCK (queue);
@@ -1114,6 +1151,9 @@
     GST_CAT_DEBUG_OBJECT (queue_dataflow, queue, "queue is empty");
     GST_QUEUE_MUTEX_LOCK_CHECK (queue, out_flushing);
 
+    /* we can start a burst to fill the memory */
+    GST_QUEUE_SIGNAL_BURST (queue);
+
     /* we recheck, the signal could have changed the thresholds */
     while (gst_queue_is_empty (queue)) {
       GST_QUEUE_WAIT_ADD_CHECK (queue, out_flushing);
@@ -1142,6 +1182,7 @@
     gst_pad_pause_task (queue->srcpad);
     GST_CAT_LOG_OBJECT (queue_dataflow, queue,
         "pause task, reason:  %s", gst_flow_get_name (queue->srcresult));
+    GST_QUEUE_SIGNAL_BURST (queue);
     GST_QUEUE_SIGNAL_DEL (queue);
     GST_QUEUE_MUTEX_UNLOCK (queue);
     return;
@@ -1343,6 +1384,9 @@
     gst_queue_leak_downstream (queue);
   }
 
+  /* unlock the burst */
+  GST_QUEUE_SIGNAL_BURST (queue);
+
   /* changing the capacity of the queue must wake up
    * the _chain function, it might have more room now
    * to store the buffer/event in the queue */
@@ -1397,6 +1441,9 @@
     case ARG_LEAKY:
       queue->leaky = g_value_get_enum (value);
       break;
+    case ARG_LOAD_BURST:
+      queue->burst = g_value_get_boolean (value);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -1444,6 +1491,9 @@
     case ARG_LEAKY:
       g_value_set_enum (value, queue->leaky);
       break;
+    case ARG_LOAD_BURST:
+      g_value_set_boolean (value, queue->burst);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
--- gstreamer.orig/plugins/elements/gstqueue.h
+++ gstreamer/plugins/elements/gstqueue.h
@@ -102,6 +102,10 @@
   /* whether we leak data, and at which end */
   gint leaky;
 
+  gboolean burst; /* burst mode */
+  gboolean burst_wait; /* queue must wait to fill with new data */
+  GCond *burst_cond; /* signal that we allow data again*/
+
   GMutex *qlock;	/* lock for queue (vs object lock) */
   GCond *item_add;	/* signals buffers now available for reading */
   GCond *item_del;	/* signals space now available for writing */
