summaryrefslogtreecommitdiffstats
path: root/src/uca-ring-buffer.c
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@gmail.com>2014-02-14 16:20:12 +0100
committerMatthias Vogelgesang <matthias.vogelgesang@gmail.com>2014-02-14 16:20:12 +0100
commitab7c4e1b75c3954d4c52a31e869dc8311a2dfc04 (patch)
tree6e002e95258e4e736c58f5187ff93cf83579541b /src/uca-ring-buffer.c
parentf15d21389a81f8df36b00113aed5c81d27143861 (diff)
parent961e60a89bc60e760707892539ccd7c6d283ef01 (diff)
downloaduca-ab7c4e1b75c3954d4c52a31e869dc8311a2dfc04.tar.gz
uca-ab7c4e1b75c3954d4c52a31e869dc8311a2dfc04.tar.bz2
uca-ab7c4e1b75c3954d4c52a31e869dc8311a2dfc04.tar.xz
uca-ab7c4e1b75c3954d4c52a31e869dc8311a2dfc04.zip
Merge pull request #31 from ufo-kit/add-frame-buffering
Add buffered recording to base class
Diffstat (limited to 'src/uca-ring-buffer.c')
-rw-r--r--src/uca-ring-buffer.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/uca-ring-buffer.c b/src/uca-ring-buffer.c
index 98ede8f..26558d7 100644
--- a/src/uca-ring-buffer.c
+++ b/src/uca-ring-buffer.c
@@ -30,7 +30,6 @@ struct _UcaRingBufferPrivate {
guint read_index;
guint read;
guint written;
- gboolean full;
};
enum {
@@ -62,7 +61,6 @@ uca_ring_buffer_reset (UcaRingBuffer *buffer)
buffer->priv->write_index = 0;
buffer->priv->read_index = 0;
- buffer->priv->full = FALSE;
}
gsize
@@ -97,6 +95,8 @@ uca_ring_buffer_get_read_pointer (UcaRingBuffer *buffer)
g_return_val_if_fail (UCA_IS_RING_BUFFER (buffer), NULL);
priv = buffer->priv;
+
+ g_return_val_if_fail (priv->read_index != priv->write_index, NULL);
data = priv->data + (priv->read_index % priv->n_blocks_total) * priv->block_size;
priv->read_index++;
return data;
@@ -112,14 +112,17 @@ uca_ring_buffer_get_write_pointer (UcaRingBuffer *buffer)
priv = buffer->priv;
data = priv->data + (priv->write_index % priv->n_blocks_total) * priv->block_size;
- priv->write_index++;
-
- if ((priv->write_index - priv->read_index) == priv->n_blocks_total)
- priv->full = TRUE;
return data;
}
+void
+uca_ring_buffer_write_advance (UcaRingBuffer *buffer)
+{
+ g_return_if_fail (UCA_IS_RING_BUFFER (buffer));
+ buffer->priv->write_index++;
+}
+
gpointer
uca_ring_buffer_peek_pointer (UcaRingBuffer *buffer)
{