#define QUEUE_IS_USING_RING_BUFFER(queue) ((queue)->use_ring_buffer) /* for consistency with the above macro */
#define QUEUE_IS_USING_QUEUE(queue) (!QUEUE_IS_USING_TEMP_FILE(queue) && !QUEUE_IS_USING_RING_BUFFER (queue))
+#define QUEUE_MAX_BYTES(queue) MIN((queue)->max_level.bytes, (queue)->ring_buffer_max_size)
+
/* default property values */
#define DEFAULT_MAX_SIZE_BUFFERS 100 /* 100 buffers */
#define DEFAULT_MAX_SIZE_BYTES (2 * 1024 * 1024) /* 2 MB */
update_cur_pos (queue, queue->current, offset + length);
GST_INFO_OBJECT (queue, "cur_level.bytes %u (max %u)",
- queue->cur_level.bytes, MIN (queue->max_level.bytes,
- queue->ring_buffer_max_size));
+ queue->cur_level.bytes, QUEUE_MAX_BYTES (queue));
/* we have a range for offset */
GST_DEBUG_OBJECT (queue,
guint64 file_offset;
guint block_length, remaining, read_length;
gint64 read_return;
+ guint64 rb_size;
/* allocate the output buffer of the requested size */
buf = gst_buffer_new_and_alloc (length);
GST_DEBUG_OBJECT (queue, "Reading %u bytes from %" G_GUINT64_FORMAT, length,
offset);
+ rb_size = queue->ring_buffer_max_size;
+
remaining = length;
while (remaining > 0) {
/* configure how much/whether to read */
", level %" G_GUINT64_FORMAT,
queue->current->reading_pos, queue->current->writing_pos, level);
- if (level >= queue->ring_buffer_max_size) {
+ if (level >= rb_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 %d bytes",
- queue->ring_buffer_max_size);
- read_length = queue->ring_buffer_max_size;
+ rb_size);
+ read_length = rb_size;
}
}
if (read_length == 0) {
if (QUEUE_IS_USING_RING_BUFFER (queue)) {
file_offset =
(queue->current->rb_offset + (offset -
- queue->current->offset)) % queue->ring_buffer_max_size;
- if (file_offset + read_length > queue->ring_buffer_max_size) {
- block_length = queue->ring_buffer_max_size - file_offset;
+ queue->current->offset)) % rb_size;
+ if (file_offset + read_length > rb_size) {
+ block_length = rb_size - file_offset;
} else {
block_length = read_length;
}
file_offset += read_return;
if (QUEUE_IS_USING_RING_BUFFER (queue))
- file_offset %= queue->ring_buffer_max_size;
+ file_offset %= rb_size;
data += read_return;
read_length -= read_return;
{
GstBuffer *buf, *rem;
guint buf_size, rem_size;
- const guint rb_size = queue->ring_buffer_max_size;
+ guint rb_size;
guint8 *data;
guint64 writing_pos, new_writing_pos;
gint64 space, rb_space;
GstQueue2Range *range, *prev;
writing_pos = queue->current->rb_writing_pos;
+ rb_size = queue->ring_buffer_max_size;
rem = buffer;
do {
/* calculate the space in the ring buffer not used by data from the
* current range */
- space =
- MIN (queue->max_level.bytes,
- queue->ring_buffer_max_size) - queue->cur_level.bytes;
+ space = QUEUE_MAX_BYTES (queue) - queue->cur_level.bytes;
space = MIN (space, rb_space);
rem_size = GST_BUFFER_SIZE (rem);
update_cur_level (queue, queue->current);
GST_INFO_OBJECT (queue, "cur_level.bytes %u (max %u)",
- queue->cur_level.bytes, MIN (queue->max_level.bytes,
- queue->ring_buffer_max_size));
+ queue->cur_level.bytes, QUEUE_MAX_BYTES (queue));
GST_QUEUE2_SIGNAL_ADD (queue);