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.
This commit is contained in:
Wim Taymans 2012-04-05 09:56:52 +02:00
parent 0bb0c68566
commit 9a1185673e

View file

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