diff options
author | David Robillard <d@drobilla.net> | 2009-02-16 00:16:28 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2009-02-16 00:16:28 +0000 |
commit | 473170200d3ce2a96b1425b6dfd57003124d8276 (patch) | |
tree | 539eda453e4e56e8acc8ed7ee82f5cfaf0f72d8f /libs/ardour/ardour/midi_buffer.h | |
parent | 1380f4fafbdf7dcc5f6f699c57ebf53621f84078 (diff) |
Rewrite Sequence::const_iterator.
Fixes crash bug when seeking back and forth from start to end of session.
Not sure about other things, but it makes a lot more sense now anyway...
git-svn-id: svn://localhost/ardour2/branches/3.0@4590 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/ardour/midi_buffer.h')
-rw-r--r-- | libs/ardour/ardour/midi_buffer.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/libs/ardour/ardour/midi_buffer.h b/libs/ardour/ardour/midi_buffer.h index 8ea5e32e81..4cd4cfea6b 100644 --- a/libs/ardour/ardour/midi_buffer.h +++ b/libs/ardour/ardour/midi_buffer.h @@ -52,25 +52,25 @@ public: bool merge(const MidiBuffer& a, const MidiBuffer& b); bool merge_in_place(const MidiBuffer &other); - template<typename BufferType, typename MIDIEventType> + template<typename BufferType, typename EventType> struct iterator_base { - iterator_base<BufferType, MIDIEventType>(BufferType& b, size_t o) : buffer(b), offset(o) {} - inline MIDIEventType operator*() const { + iterator_base<BufferType, EventType>(BufferType& b, size_t o) : buffer(b), offset(o) {} + inline EventType operator*() const { uint8_t* ev_start = buffer._data + offset + sizeof(TimeType); int event_size = Evoral::midi_event_size(ev_start); assert(event_size >= 0); - return MIDIEventType(EventTypeMap::instance().midi_event_type(*ev_start), + return EventType(EventTypeMap::instance().midi_event_type(*ev_start), *((TimeType*)(buffer._data + offset)), event_size, ev_start); } - inline iterator_base<BufferType, MIDIEventType>& operator++() { + inline iterator_base<BufferType, EventType>& operator++() { uint8_t* ev_start = buffer._data + offset + sizeof(TimeType); int event_size = Evoral::midi_event_size(ev_start); assert(event_size >= 0); offset += sizeof(TimeType) + event_size; return *this; } - inline bool operator!=(const iterator_base<BufferType, MIDIEventType>& other) const { + inline bool operator!=(const iterator_base<BufferType, EventType>& other) const { return (&buffer != &other.buffer) || (offset != other.offset); } BufferType& buffer; |