diff options
author | David Robillard <d@drobilla.net> | 2009-02-02 02:36:05 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2009-02-02 02:36:05 +0000 |
commit | 166ef64e3db4ab72b7b1e7455234e2b9ceddf6d8 (patch) | |
tree | 0f28067a301556c5c0a67091c691c82960db57c1 /libs/evoral/src/Event.cpp | |
parent | ead5dd45689be089d79a4a5daad88da737ca4cd9 (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/src/Event.cpp')
-rw-r--r-- | libs/evoral/src/Event.cpp | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/libs/evoral/src/Event.cpp b/libs/evoral/src/Event.cpp index 5ac38d6357..1f1460655f 100644 --- a/libs/evoral/src/Event.cpp +++ b/libs/evoral/src/Event.cpp @@ -22,47 +22,52 @@ namespace Evoral { #ifdef EVORAL_EVENT_ALLOC -Event::Event(uint32_t tid, EventTime t, uint32_t s, uint8_t* b, bool owns_buffer) +template<typename T> +Event<T>::Event(uint32_t tid, T t, uint32_t s, uint8_t* b, bool owns_buf) : _type(tid) , _time(t) , _size(s) - , _buffer(b) - , _owns_buffer(owns_buffer) + , _buf(b) + , _owns_buf(owns_buf) { - if (owns_buffer) { - _buffer = (uint8_t*)malloc(_size); + if (owns_buf) { + _buf = (uint8_t*)malloc(_size); if (b) { - memcpy(_buffer, b, _size); + memcpy(_buf, b, _size); } else { - memset(_buffer, 0, _size); + memset(_buf, 0, _size); } } } -Event::Event(const Event& copy, bool owns_buffer) +template<typename T> +Event<T>::Event(const Event& copy, bool owns_buf) : _type(copy._type) , _time(copy._time) , _size(copy._size) - , _buffer(copy._buffer) - , _owns_buffer(owns_buffer) + , _buf(copy._buf) + , _owns_buf(owns_buf) { - if (owns_buffer) { - _buffer = (uint8_t*)malloc(_size); - if (copy._buffer) { - memcpy(_buffer, copy._buffer, _size); + if (owns_buf) { + _buf = (uint8_t*)malloc(_size); + if (copy._buf) { + memcpy(_buf, copy._buf, _size); } else { - memset(_buffer, 0, _size); + memset(_buf, 0, _size); } } } -Event::~Event() { - if (_owns_buffer) { - free(_buffer); +template<typename T> +Event<T>::~Event() { + if (_owns_buf) { + free(_buf); } } #endif // EVORAL_EVENT_ALLOC -} // namespace MIDI +template class Event<double>; + +} // namespace Evoral |