diff options
author | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2013-04-10 09:02:09 +0200 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2013-04-10 09:02:09 +0200 |
commit | 0ef77576760e3b384ff15f6155c6073ab96fc8c7 (patch) | |
tree | 0951d48033ece37fdacd9745529de2a6deb43a0b /tools/gui | |
parent | 617a46bff0cda0a30e30e5173f1666b2338bff25 (diff) | |
download | uca-0ef77576760e3b384ff15f6155c6073ab96fc8c7.tar.gz uca-0ef77576760e3b384ff15f6155c6073ab96fc8c7.tar.bz2 uca-0ef77576760e3b384ff15f6155c6073ab96fc8c7.tar.xz uca-0ef77576760e3b384ff15f6155c6073ab96fc8c7.zip |
grab takes -n and -t parameters now
Diffstat (limited to 'tools/gui')
-rw-r--r-- | tools/gui/CMakeLists.txt | 3 | ||||
-rw-r--r-- | tools/gui/ring-buffer.c | 64 | ||||
-rw-r--r-- | tools/gui/ring-buffer.h | 28 |
3 files changed, 2 insertions, 93 deletions
diff --git a/tools/gui/CMakeLists.txt b/tools/gui/CMakeLists.txt index 1000ac6..07f597b 100644 --- a/tools/gui/CMakeLists.txt +++ b/tools/gui/CMakeLists.txt @@ -18,6 +18,7 @@ include_directories( ${GOBJECT2_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR}/../../src/ ${CMAKE_CURRENT_SOURCE_DIR}/../../src + ${CMAKE_CURRENT_SOURCE_DIR}/../ ) if (GTK2_FOUND) @@ -25,7 +26,7 @@ if (GTK2_FOUND) add_executable(control control.c - ring-buffer.c + ../ring-buffer.c # yes this sucks and should be fixed egg-property-cell-renderer.c egg-property-tree-view.c egg-histogram-view.c) diff --git a/tools/gui/ring-buffer.c b/tools/gui/ring-buffer.c deleted file mode 100644 index ec2638c..0000000 --- a/tools/gui/ring-buffer.c +++ /dev/null @@ -1,64 +0,0 @@ - -#include <math.h> -#include "ring-buffer.h" - -RingBuffer * -ring_buffer_new (gsize block_size, - gsize n_blocks) -{ - RingBuffer *buffer; - - buffer = g_new0 (RingBuffer, 1); - buffer->block_size = block_size; - buffer->n_blocks_total = n_blocks; - buffer->n_blocks_used = 0; - buffer->current_index = 0; - buffer->data = g_malloc0_n (n_blocks, block_size); - - return buffer; -} - -void -ring_buffer_free (RingBuffer *buffer) -{ - g_free (buffer->data); - g_free (buffer); -} - -void -ring_buffer_reset (RingBuffer *buffer) -{ - buffer->n_blocks_used = 0; - buffer->current_index = 0; -} - -gpointer -ring_buffer_get_current_pointer (RingBuffer *buffer) -{ - return buffer->data + (buffer->current_index % buffer->n_blocks_total) * buffer->block_size; -} - -gpointer -ring_buffer_get_pointer (RingBuffer *buffer, - guint index) -{ - g_assert (index < buffer->n_blocks_total); - return buffer->data + ((buffer->current_index - buffer->n_blocks_used + index) % buffer->n_blocks_total) * buffer->block_size; -} - -guint -ring_buffer_get_num_blocks (RingBuffer *buffer) -{ - return buffer->n_blocks_used; -} - -void -ring_buffer_proceed (RingBuffer *buffer) -{ - buffer->current_index++; - - if (buffer->n_blocks_used < buffer->n_blocks_total) - buffer->n_blocks_used++; - else - buffer->current_index = buffer->current_index % buffer->n_blocks_total; -} diff --git a/tools/gui/ring-buffer.h b/tools/gui/ring-buffer.h deleted file mode 100644 index 9966eb7..0000000 --- a/tools/gui/ring-buffer.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef RING_BUFFER_H -#define RING_BUFFER_H - -#include <glib.h> - -G_BEGIN_DECLS - -typedef struct { - guchar *data; - gsize block_size; - guint n_blocks_total; - guint n_blocks_used; - guint current_index; -} RingBuffer; - -RingBuffer * ring_buffer_new (gsize block_size, - gsize n_blocks); -void ring_buffer_free (RingBuffer *buffer); -void ring_buffer_reset (RingBuffer *buffer); -gpointer ring_buffer_get_current_pointer (RingBuffer *buffer); -gpointer ring_buffer_get_pointer (RingBuffer *buffer, - guint index); -guint ring_buffer_get_num_blocks (RingBuffer *buffer); -void ring_buffer_proceed (RingBuffer *buffer); - -G_END_DECLS - -#endif |