From c61373212a87e519276d4c011994e2d37c77ee16 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 8 Nov 2016 20:34:45 -0500 Subject: Support multiple readers for MIDI source/model Fixes the multiple reader issue #6541 properly without resorting to a linear search kludge. All the read state has been pulled out into a MidiCursor which the caller is required to pass. The playlist keeps cursors for all the regions it is reading, any number of cursors are allowed at a time. MidiCursor should probably be made a smarter and more fool-proof object (and/or possibly merged with some of the other tracker/fixer stuff) but for now I wanted to keep it simple. --- libs/ardour/ardour/midi_source.h | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'libs/ardour/ardour/midi_source.h') diff --git a/libs/ardour/ardour/midi_source.h b/libs/ardour/ardour/midi_source.h index 4815263739..1ff0a08f71 100644 --- a/libs/ardour/ardour/midi_source.h +++ b/libs/ardour/ardour/midi_source.h @@ -36,8 +36,9 @@ namespace ARDOUR { class MidiChannelFilter; -class MidiStateTracker; +class MidiCursor; class MidiModel; +class MidiStateTracker; template class MidiRingBuffer; @@ -87,18 +88,18 @@ class LIBARDOUR_API MidiSource : virtual public Source, public boost::enable_sha * \param tracker an optional pointer to MidiStateTracker object, for note on/off tracking. * \param filtered Parameters whose MIDI messages will not be returned. */ - virtual framecnt_t midi_read (const Lock& lock, Evoral::EventSink& dst, framepos_t source_start, framepos_t start, framecnt_t cnt, Evoral::Range* loop_range, + MidiCursor& cursor, MidiStateTracker* tracker, MidiChannelFilter* filter, const std::set& filtered, - const double pulse, - const double start_beats) const; + const double pulse, + const double start_beats) const; /** Write data from a MidiRingBuffer to this source. * @param source Source to read from. @@ -175,10 +176,11 @@ class LIBARDOUR_API MidiSource : virtual public Source, public boost::enable_sha /** Reset cached information (like iterators) when things have changed. * @param lock Source lock, which must be held by caller. - * @param notes If non-NULL, currently active notes are added to this set. */ - void invalidate(const Glib::Threads::Mutex::Lock& lock, - std::set::WeakNotePtr>* notes=NULL); + void invalidate(const Glib::Threads::Mutex::Lock& lock); + + /** Thou shalt not emit this directly, use invalidate() instead. */ + mutable PBD::Signal1 Invalidated; void set_note_mode(const Glib::Threads::Mutex::Lock& lock, NoteMode mode); @@ -230,11 +232,7 @@ class LIBARDOUR_API MidiSource : virtual public Source, public boost::enable_sha boost::shared_ptr _model; bool _writing; - mutable Evoral::Sequence::const_iterator _model_iter; - mutable bool _model_iter_valid; - - mutable Evoral::Beats _length_beats; - mutable framepos_t _last_read_end; + Evoral::Beats _length_beats; /** The total duration of the current capture. */ framepos_t _capture_length; -- cgit v1.2.3