Update the buffering state before stalling for more data
authorGustavo Noronha Silva <gns@gnome.org>
Fri, 6 Sep 2013 18:09:46 +0000 (15:09 -0300)
committerSebastian Dröge <slomo@circular-chaos.org>
Mon, 9 Sep 2013 12:15:09 +0000 (14:15 +0200)
In some cases the wait for more data was happening without updating
the buffering state, meaning the API user would not be able to notice
it should pause the pipeline and update UI to indicate that is the
case, the video would likely stutter instead.

https://bugzilla.gnome.org/show_bug.cgi?id=707648

plugins/elements/gstqueue2.c

index eb842a461179c20f61fec569920ec01ee2ffbaa5..6bef04d5bd5629616604e6c76181a279387294a0 100644 (file)
@@ -255,6 +255,7 @@ static gboolean gst_queue2_is_empty (GstQueue2 * queue);
 static gboolean gst_queue2_is_filled (GstQueue2 * queue);
 
 static void update_cur_level (GstQueue2 * queue, GstQueue2Range * range);
+static void update_in_rates (GstQueue2 * queue);
 
 typedef enum
 {
@@ -875,6 +876,10 @@ update_buffering (GstQueue2 * queue)
   gint percent;
   gboolean post = FALSE;
 
+  /* Ensure the variables used to calculate buffering state are up-to-date. */
+  update_cur_level (queue, queue->current);
+  update_in_rates (queue);
+
   if (!get_buffering_percent (queue, NULL, &percent))
     return;
 
@@ -1285,6 +1290,10 @@ gst_queue2_create_read (GstQueue2 * queue, guint64 offset, guint length,
           update_cur_pos (queue, queue->current, rpos);
           GST_QUEUE2_SIGNAL_DEL (queue);
         }
+
+        if (queue->use_buffering)
+          update_buffering (queue);
+
         GST_DEBUG_OBJECT (queue, "waiting for add");
         GST_QUEUE2_WAIT_ADD_CHECK (queue, queue->srcresult, out_flushing);
         continue;