-bool
-MidiRingBufferBase<T>::full_peek(size_t size, T* dst)
-{
- if (read_space() < size) {
- return false;
- }
-
- const size_t read_size = peek(size, dst);
-
- if (read_size < size) {
- peek(size - read_size, dst + read_size);
- }
-
- return true;
-}
-
-
-/** Read from the ringbuffer.
- *
- * Note that a full read may not be done if the data wraps around.
- * Caller must check return value and call again if necessary, or use the
- * full_read method which does this automatically.
- */
-template<typename T>
-size_t
-MidiRingBufferBase<T>::read(size_t size, T* dst)
-{
- const size_t priv_read_ptr = g_atomic_int_get(&_read_ptr);
-
- const size_t read_size = (priv_read_ptr + size < _size)
- ? size
- : _size - priv_read_ptr;
-
- memcpy(dst, &_buf[priv_read_ptr], read_size);
-
- g_atomic_int_set(&_read_ptr, (priv_read_ptr + read_size) % _size);
-
- return read_size;
-}
-
-
-template<typename T>
-bool
-MidiRingBufferBase<T>::full_read(size_t size, T* dst)
-{
- if (read_space() < size) {
- return false;
- }
-
- const size_t read_size = read(size, dst);
-
- if (read_size < size) {
- read(size - read_size, dst + read_size);
- }
-
- return true;
-}
-
-
-template<typename T>
-bool
-MidiRingBufferBase<T>::skip(size_t size)
-{
- if (read_space() < size) {
- std::cerr << "WARNING: Attempt to skip past end of MIDI ring buffer" << std::endl;
- return false;
- }
-
- const size_t priv_read_ptr = g_atomic_int_get(&_read_ptr);
- g_atomic_int_set(&_read_ptr, (priv_read_ptr + size) % _size);
-
- return true;
-}
-
-
-template<typename T>
-inline void
-MidiRingBufferBase<T>::write(size_t size, const T* src)
-{
- const size_t priv_write_ptr = g_atomic_int_get(&_write_ptr);
-
- if (priv_write_ptr + size <= _size) {
- memcpy(&_buf[priv_write_ptr], src, size);
- g_atomic_int_set(&_write_ptr, (priv_write_ptr + size) % _size);
- } else {
- const size_t this_size = _size - priv_write_ptr;
- assert(this_size < size);
- assert(priv_write_ptr + this_size <= _size);
- memcpy(&_buf[priv_write_ptr], src, this_size);
- memcpy(&_buf[0], src+this_size, size - this_size);
- g_atomic_int_set(&_write_ptr, size - this_size);
- }
-}
-
-
-/* ******************************************************************** */
-
-
-/** A MIDI RingBuffer.
- *
- * This is timestamps and MIDI packed sequentially into a single buffer, similarly
- * to LV2 MIDI. The buffer looks like this:
- *
- * [timestamp][size][size bytes of raw MIDI][timestamp][size][etc..]
- */
-class MidiRingBuffer : public MidiRingBufferBase<uint8_t> {