diff options
author | David Robillard <d@drobilla.net> | 2009-02-17 06:09:37 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2009-02-17 06:09:37 +0000 |
commit | f219a53744c3ccced52070a0ebab5fbe7f9b9895 (patch) | |
tree | 6b7e01c874b62208043b2b97150c08f89249b33b /libs/evoral | |
parent | 3f24977735b06f9b39a82d66c216ba27e3a302d5 (diff) |
Fix deadlock and potential race condition when editing MIDI.
git-svn-id: svn://localhost/ardour2/branches/3.0@4614 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/evoral')
-rw-r--r-- | libs/evoral/evoral/Sequence.hpp | 10 | ||||
-rw-r--r-- | libs/evoral/src/Sequence.cpp | 24 |
2 files changed, 24 insertions, 10 deletions
diff --git a/libs/evoral/evoral/Sequence.hpp b/libs/evoral/evoral/Sequence.hpp index 30c1c1f0ca..ee18af50dc 100644 --- a/libs/evoral/evoral/Sequence.hpp +++ b/libs/evoral/evoral/Sequence.hpp @@ -63,8 +63,6 @@ class Sequence : virtual public ControlSet { public: Sequence(const TypeMap& type_map, size_t size=0); - bool read_locked() { return _read_iter.locked(); } - void write_lock(); void write_unlock(); @@ -126,6 +124,8 @@ public: inline bool valid() const { return !_is_end && _event; } inline bool locked() const { return _locked; } + + void invalidate(); const Event<Time>& operator*() const { return *_event; } const boost::shared_ptr< Event<Time> > operator->() const { return _event; } @@ -159,9 +159,6 @@ public: const_iterator begin(Time t=0) const { return const_iterator(*this, t); } const const_iterator& end() const { return _end_iter; } - void read_seek(Time t) { _read_iter = begin(t); } - Time read_time() const { return _read_iter.valid() ? _read_iter->time() : 0.0; } - bool control_to_midi_event(boost::shared_ptr< Event<Time> >& ev, const ControlIterator& iter) const; @@ -175,8 +172,7 @@ public: uint8_t highest_note() const { return _highest_note; } protected: - mutable const_iterator _read_iter; - bool _edited; + bool _edited; private: friend class const_iterator; diff --git a/libs/evoral/src/Sequence.cpp b/libs/evoral/src/Sequence.cpp index c5deda554b..4328332c5b 100644 --- a/libs/evoral/src/Sequence.cpp +++ b/libs/evoral/src/Sequence.cpp @@ -225,6 +225,26 @@ Sequence<Time>::const_iterator::~const_iterator() } template<typename Time> +void +Sequence<Time>::const_iterator::invalidate() +{ + while (!_active_notes.empty()) { + _active_notes.pop(); + } + _type = NIL; + _is_end = true; + if (_seq) { + _note_iter = _seq->notes().end(); + _sysex_iter = _seq->sysexes().end(); + } + _control_iter = _control_iters.end(); + if (_locked) { + _seq->read_unlock(); + _locked = false; + } +} + +template<typename Time> const typename Sequence<Time>::const_iterator& Sequence<Time>::const_iterator::operator++() { @@ -407,8 +427,7 @@ Sequence<Time>::const_iterator::operator=(const const_iterator& other) template<typename Time> Sequence<Time>::Sequence(const TypeMap& type_map, size_t size) - : _read_iter(*this, DBL_MAX) - , _edited(false) + : _edited(false) , _type_map(type_map) , _notes(size) , _writing(false) @@ -508,7 +527,6 @@ Sequence<Time>::clear() _notes.clear(); for (Controls::iterator li = _controls.begin(); li != _controls.end(); ++li) li->second->list()->clear(); - _read_iter = end(); _lock.writer_unlock(); } |