diff options
author | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2012-10-15 10:33:14 +0200 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2012-10-15 10:33:14 +0200 |
commit | 33a90d8dc20a513722f5fdf66a99cff91be422d5 (patch) | |
tree | ecbedb9ca7dc0d0858736b86f12c4972051223be /tools/gui/ring-buffer.c | |
parent | 6d4826f326f981a207ed6d64d5c481d0b1bddd00 (diff) | |
download | uca-33a90d8dc20a513722f5fdf66a99cff91be422d5.tar.gz uca-33a90d8dc20a513722f5fdf66a99cff91be422d5.tar.bz2 uca-33a90d8dc20a513722f5fdf66a99cff91be422d5.tar.xz uca-33a90d8dc20a513722f5fdf66a99cff91be422d5.zip |
Fix replay feature
Diffstat (limited to 'tools/gui/ring-buffer.c')
-rw-r--r-- | tools/gui/ring-buffer.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/tools/gui/ring-buffer.c b/tools/gui/ring-buffer.c index 5915d2a..ec2638c 100644 --- a/tools/gui/ring-buffer.c +++ b/tools/gui/ring-buffer.c @@ -12,7 +12,7 @@ ring_buffer_new (gsize block_size, buffer->block_size = block_size; buffer->n_blocks_total = n_blocks; buffer->n_blocks_used = 0; - buffer->start_index = 0; + buffer->current_index = 0; buffer->data = g_malloc0_n (n_blocks, block_size); return buffer; @@ -29,13 +29,13 @@ void ring_buffer_reset (RingBuffer *buffer) { buffer->n_blocks_used = 0; - buffer->start_index = 0; + buffer->current_index = 0; } gpointer ring_buffer_get_current_pointer (RingBuffer *buffer) { - return ring_buffer_get_pointer (buffer, 0); + return buffer->data + (buffer->current_index % buffer->n_blocks_total) * buffer->block_size; } gpointer @@ -43,7 +43,7 @@ ring_buffer_get_pointer (RingBuffer *buffer, guint index) { g_assert (index < buffer->n_blocks_total); - return buffer->data + ((buffer->start_index + index) % buffer->n_blocks_total) * buffer->block_size; + return buffer->data + ((buffer->current_index - buffer->n_blocks_used + index) % buffer->n_blocks_total) * buffer->block_size; } guint @@ -55,10 +55,10 @@ ring_buffer_get_num_blocks (RingBuffer *buffer) void ring_buffer_proceed (RingBuffer *buffer) { - buffer->start_index++; + buffer->current_index++; if (buffer->n_blocks_used < buffer->n_blocks_total) buffer->n_blocks_used++; else - buffer->start_index = buffer->start_index % buffer->n_blocks_total; + buffer->current_index = buffer->current_index % buffer->n_blocks_total; } |