queue2: update current read position before waiting
authorWim Taymans <wim.taymans@collabora.co.uk>
Wed, 11 Apr 2012 10:02:50 +0000 (12:02 +0200)
committerWim Taymans <wim.taymans@collabora.co.uk>
Wed, 11 Apr 2012 10:45:41 +0000 (12:45 +0200)
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.

plugins/elements/gstqueue2.c

index a861fb7..f0dd2ec 100644 (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);