summaryrefslogtreecommitdiff
path: root/libs/evoral/evoral/EventRingBuffer.hpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-02-02 02:36:05 +0000
committerDavid Robillard <d@drobilla.net>2009-02-02 02:36:05 +0000
commit166ef64e3db4ab72b7b1e7455234e2b9ceddf6d8 (patch)
tree0f28067a301556c5c0a67091c691c82960db57c1 /libs/evoral/evoral/EventRingBuffer.hpp
parentead5dd45689be089d79a4a5daad88da737ca4cd9 (diff)
Make (MIDI) event time stamp type a template parameter.
git-svn-id: svn://localhost/ardour2/branches/3.0@4473 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/evoral/evoral/EventRingBuffer.hpp')
-rw-r--r--libs/evoral/evoral/EventRingBuffer.hpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/libs/evoral/evoral/EventRingBuffer.hpp b/libs/evoral/evoral/EventRingBuffer.hpp
index cc7b617e26..92d366387f 100644
--- a/libs/evoral/evoral/EventRingBuffer.hpp
+++ b/libs/evoral/evoral/EventRingBuffer.hpp
@@ -34,7 +34,8 @@ namespace Evoral {
* This packs a timestamp, size, and size bytes of data flat into the buffer.
* Useful for MIDI events, OSC messages, etc.
*/
-class EventRingBuffer : public Evoral::RingBuffer<uint8_t>, public Evoral::EventSink {
+template<typename T>
+class EventRingBuffer : public Evoral::RingBuffer<uint8_t>, public Evoral::EventSink<T> {
public:
/** @param capacity Ringbuffer capacity in bytes.
@@ -44,25 +45,27 @@ public:
size_t capacity() const { return _size; }
- bool peek_time(EventTime* time);
+ bool peek_time(T* time);
- uint32_t write(EventTime time, EventType type, uint32_t size, const uint8_t* buf);
- bool read (EventTime* time, EventType* type, uint32_t* size, uint8_t* buf);
+ uint32_t write(T time, EventType type, uint32_t size, const uint8_t* buf);
+ bool read (T* time, EventType* type, uint32_t* size, uint8_t* buf);
};
+template<typename T>
inline bool
-EventRingBuffer::peek_time(EventTime* time)
+EventRingBuffer<T>::peek_time(T* time)
{
- bool success = RingBuffer<uint8_t>::full_peek(sizeof(EventTime), (uint8_t*)time);
+ bool success = RingBuffer<uint8_t>::full_peek(sizeof(T), (uint8_t*)time);
return success;
}
+template<typename T>
inline bool
-EventRingBuffer::read(EventTime* time, EventType* type, uint32_t* size, uint8_t* buf)
+EventRingBuffer<T>::read(T* time, EventType* type, uint32_t* size, uint8_t* buf)
{
- bool success = RingBuffer<uint8_t>::full_read(sizeof(EventTime), (uint8_t*)time);
+ bool success = RingBuffer<uint8_t>::full_read(sizeof(T), (uint8_t*)time);
if (success)
success = RingBuffer<uint8_t>::full_read(sizeof(EventType), (uint8_t*)type);
if (success)
@@ -74,13 +77,14 @@ EventRingBuffer::read(EventTime* time, EventType* type, uint32_t* size, uint8_t*
}
+template<typename T>
inline uint32_t
-EventRingBuffer::write(EventTime time, EventType type, uint32_t size, const uint8_t* buf)
+EventRingBuffer<T>::write(T time, EventType type, uint32_t size, const uint8_t* buf)
{
- if (write_space() < (sizeof(EventTime) + sizeof(EventType) + sizeof(uint32_t) + size)) {
+ if (write_space() < (sizeof(T) + sizeof(EventType) + sizeof(uint32_t) + size)) {
return 0;
} else {
- RingBuffer<uint8_t>::write(sizeof(EventTime), (uint8_t*)&time);
+ RingBuffer<uint8_t>::write(sizeof(T), (uint8_t*)&time);
RingBuffer<uint8_t>::write(sizeof(EventType), (uint8_t*)&type);
RingBuffer<uint8_t>::write(sizeof(uint32_t), (uint8_t*)&size);
RingBuffer<uint8_t>::write(size, buf);