queue2: update current read position before waiting

When we don't have enough bytes in the ringbuffer to satisfy the current
request, first update the current read position before waiting. If we don't do
that, the ringbuffer might appear full and the writer will never write more
bytes to wake us up.
This commit is contained in:
Wim Taymans 2012-04-11 12:02:50 +02:00
parent 463a8d9abf
commit ccbeb19881

View file

@ -1304,15 +1304,11 @@ gst_queue2_create_read (GstQueue2 * queue, guint64 offset, guint length,
}
if (read_length == 0) {
if (QUEUE_IS_USING_RING_BUFFER (queue)
&& queue->current->max_reading_pos > rpos) {
/* protect cached data (data between offset and max_reading_pos)
* and update current level */
if (QUEUE_IS_USING_RING_BUFFER (queue)) {
GST_DEBUG_OBJECT (queue,
"protecting cached data [%" G_GUINT64_FORMAT "-%" G_GUINT64_FORMAT
"]", rpos, queue->current->max_reading_pos);
queue->current->max_reading_pos = rpos;
update_cur_level (queue, queue->current);
"update current position [%" G_GUINT64_FORMAT "-%"
G_GUINT64_FORMAT "]", rpos, queue->current->max_reading_pos);
update_cur_pos (queue, queue->current, rpos);
}
GST_DEBUG_OBJECT (queue, "waiting for add");
GST_QUEUE2_WAIT_ADD_CHECK (queue, queue->srcresult, out_flushing);