gstreamer: queue2: check for filled buffer correctly

Wim Taymans wtay at kemper.freedesktop.org
Thu Apr 5 01:36:51 PDT 2012


Module: gstreamer
Branch: master
Commit: 9a1185673e7e8a5308886d08f3e5afc18491d466
URL:    http://cgit.freedesktop.org/gstreamer/gstreamer/commit/?id=9a1185673e7e8a5308886d08f3e5afc18491d466

Author: Wim Taymans <wim.taymans at collabora.co.uk>
Date:   Thu Apr  5 09:56:52 2012 +0200

queue2: check for filled buffer correctly

When using the ringbuffer mode, the buffer is filled when we reached the
max_level.bytes mark or the total size of the ringbuffer, whichever is smaller.

---

 plugins/elements/gstqueue2.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/plugins/elements/gstqueue2.c b/plugins/elements/gstqueue2.c
index 347c64a..b011cd3 100644
--- a/plugins/elements/gstqueue2.c
+++ b/plugins/elements/gstqueue2.c
@@ -1244,6 +1244,7 @@ gst_queue2_create_read (GstQueue2 * queue, guint64 offset, guint length,
   guint block_length, remaining, read_length;
   gint64 read_return;
   guint64 rb_size;
+  guint64 max_size;
   guint64 rpos;
 
   /* allocate the output buffer of the requested size */
@@ -1255,6 +1256,7 @@ gst_queue2_create_read (GstQueue2 * queue, guint64 offset, guint length,
 
   rpos = offset;
   rb_size = queue->ring_buffer_max_size;
+  max_size = QUEUE_MAX_BYTES (queue);
 
   remaining = length;
   while (remaining > 0) {
@@ -1273,16 +1275,16 @@ gst_queue2_create_read (GstQueue2 * queue, guint64 offset, guint length,
 
         GST_DEBUG_OBJECT (queue,
             "reading %" G_GUINT64_FORMAT ", writing %" G_GUINT64_FORMAT
-            ", level %" G_GUINT64_FORMAT,
-            rpos, queue->current->writing_pos, level);
+            ", level %" G_GUINT64_FORMAT ", max %" G_GUINT64_FORMAT,
+            rpos, queue->current->writing_pos, level, max_size);
 
-        if (level >= rb_size) {
+        if (level >= max_size) {
           /* we don't have the data but if we have a ring buffer that is full, we
            * need to read */
           GST_DEBUG_OBJECT (queue,
-              "ring buffer full, reading ring-buffer-max-size %"
-              G_GUINT64_FORMAT " bytes", rb_size);
-          read_length = rb_size;
+              "ring buffer full, reading QUEUE_MAX_BYTES %"
+              G_GUINT64_FORMAT " bytes", max_size);
+          read_length = max_size;
         } else if (queue->is_eos) {
           /* won't get any more data so read any data we have */
           if (level) {



More information about the gstreamer-commits mailing list