summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorHans Baier <hansfbaier@googlemail.com>2008-12-29 00:19:12 +0000
committerHans Baier <hansfbaier@googlemail.com>2008-12-29 00:19:12 +0000
commitfa71e0e12acbe0d27a618b3cfe3fa6f98f6f64ff (patch)
treea1c45df668cce5415ab26faaeaecdc5277dea791 /libs
parentc7c1753c729a7796e9f4d5927b766181c15d8ea0 (diff)
* added a bit of documentation in an effort to understand the code
git-svn-id: svn://localhost/ardour2/branches/3.0@4355 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/evoral/evoral/RingBuffer.hpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/libs/evoral/evoral/RingBuffer.hpp b/libs/evoral/evoral/RingBuffer.hpp
index a27e97adb2..0d92043174 100644
--- a/libs/evoral/evoral/RingBuffer.hpp
+++ b/libs/evoral/evoral/RingBuffer.hpp
@@ -56,6 +56,8 @@ public:
g_atomic_int_set(&_read_ptr, 0);
}
+ /** Calculate remaining space for writing
+ */
size_t write_space() const {
const size_t w = g_atomic_int_get(&_write_ptr);
const size_t r = g_atomic_int_get(&_read_ptr);
@@ -69,6 +71,8 @@ public:
}
}
+ /** Calculate how much still can be read
+ */
size_t read_space() const {
const size_t w = g_atomic_int_get(&_write_ptr);
const size_t r = g_atomic_int_get(&_read_ptr);
@@ -80,14 +84,44 @@ public:
}
}
+ /** Report the buffers size
+ */
size_t capacity() const { return _size; }
+ /** Peek at the ringbuffer (read w/o advancing read pointer).
+ * @return how much has been peeked (read cannot exceed the end
+ * of the buffer):
+ * <pre>
+ * |-------------------------R=============================|
+ * read-pointer---^
+ * </pre>
+ */
size_t peek(size_t size, T* dst);
+
+ /** Peek at the ringbuffer (read w/o advancing read pointer).
+ * @return how much has been peeked (wraps around if read exceeds
+ * the end of the buffer):
+ * <pre>
+ * |===========--------------R=============================|
+ * read-pointer---^
+ * </pre>
+ */
bool full_peek(size_t size, T* dst);
+ /** Read from the ringbuffer. (advances read pointer)
+ * @return how much has been read (read cannot exceed the end
+ * of the buffer):
+ */
size_t read(size_t size, T* dst);
+
+ /** Read from the ringbuffer. (advances read pointer)
+ * @return how much has been peeked (wraps around if read exceeds
+ * the end of the buffer):
+ */
bool full_read(size_t size, T* dst);
+ /** Advance read pointer by size
+ */
bool skip(size_t size);
void write(size_t size, const T* src);