diff options
author | Wim Taymans <wim.taymans@collabora.co.uk> | 2010-06-16 11:20:00 +0200 |
---|---|---|
committer | Wim Taymans <wim.taymans@collabora.co.uk> | 2010-08-13 16:38:55 +0200 |
commit | cb6d9b071e2ee517c0ac682454b8f64ffe02feec (patch) | |
tree | 39cfdbb562723446cc2174d1c87d266b709411e1 | |
parent | 8de7cc22223e80b3b8297095713d2eb5a412ee02 (diff) |
queue2: fix calculation of available ringbuffer data
-rw-r--r-- | plugins/elements/gstqueue2.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/plugins/elements/gstqueue2.c b/plugins/elements/gstqueue2.c index a9bfbff039..2869aa74f5 100644 --- a/plugins/elements/gstqueue2.c +++ b/plugins/elements/gstqueue2.c @@ -1193,11 +1193,20 @@ gst_queue2_create_read (GstQueue2 * queue, guint64 offset, guint length, read_length = 0; if (QUEUE_IS_USING_RING_BUFFER (queue)) { + guint64 level; + + /* calculate how far away the offset is */ + if (queue->current->writing_pos > offset) + level = queue->current->writing_pos - offset; + else + level = 0; + GST_DEBUG_OBJECT (queue, - "reading %" G_GUINT64_FORMAT ", writing %" G_GUINT64_FORMAT, - queue->current->reading_pos, queue->current->writing_pos); - if (queue->current->writing_pos - queue->current->reading_pos >= - queue->ring_buffer_max_size) { + "reading %" G_GUINT64_FORMAT ", writing %" G_GUINT64_FORMAT + ", level %" G_GUINT64_FORMAT, + queue->current->reading_pos, queue->current->writing_pos, level); + + if (level >= queue->ring_buffer_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, @@ -1246,6 +1255,7 @@ gst_queue2_create_read (GstQueue2 * queue, guint64 offset, guint length, read_length -= read_return; block_length = read_length; remaining -= read_return; + queue->current->reading_pos += read_return; } GST_QUEUE2_SIGNAL_DEL (queue); |