diff options
Diffstat (limited to 'libs/ardour')
-rw-r--r-- | libs/ardour/ardour/async_midi_port.h | 10 | ||||
-rw-r--r-- | libs/ardour/ardour/midi_port.h | 30 | ||||
-rw-r--r-- | libs/ardour/async_midi_port.cc | 38 | ||||
-rw-r--r-- | libs/ardour/midi_port.cc | 41 |
4 files changed, 60 insertions, 59 deletions
diff --git a/libs/ardour/ardour/async_midi_port.h b/libs/ardour/ardour/async_midi_port.h index acf9730e84..39fee02878 100644 --- a/libs/ardour/ardour/async_midi_port.h +++ b/libs/ardour/ardour/async_midi_port.h @@ -73,11 +73,6 @@ class LIBARDOUR_API AsyncMIDIPort : public ARDOUR::MidiPort, public MIDI::Port { int selectable() const { return -1; } void set_timer (boost::function<framecnt_t (void)>&); - typedef boost::function<bool(MidiBuffer&,MidiBuffer&)> MidiFilter; - void set_inbound_filter (MidiFilter); - int add_shadow_port (std::string const &, MidiFilter); - boost::shared_ptr<MidiPort> shadow_port() const { return _shadow_port; } - static void set_process_thread (pthread_t); static pthread_t get_process_thread () { return _process_thread; } static bool is_process_thread(); @@ -105,11 +100,6 @@ class LIBARDOUR_API AsyncMIDIPort : public ARDOUR::MidiPort, public MIDI::Port { void flush_output_fifo (pframes_t); - MidiFilter inbound_midi_filter; - - boost::shared_ptr<MidiPort> _shadow_port; - MidiFilter shadow_midi_filter; - static pthread_t _process_thread; }; diff --git a/libs/ardour/ardour/midi_port.h b/libs/ardour/ardour/midi_port.h index eb90dc1e35..3856d11ac5 100644 --- a/libs/ardour/ardour/midi_port.h +++ b/libs/ardour/ardour/midi_port.h @@ -58,6 +58,11 @@ class LIBARDOUR_API MidiPort : public Port { void set_always_parse (bool yn); void set_trace_on (bool yn); + typedef boost::function<bool(MidiBuffer&,MidiBuffer&)> MidiFilter; + void set_inbound_filter (MidiFilter); + int add_shadow_port (std::string const &, MidiFilter); + boost::shared_ptr<MidiPort> shadow_port() const { return _shadow_port; } + MIDI::Parser& self_parser() { return _self_parser; } protected: @@ -72,17 +77,20 @@ class LIBARDOUR_API MidiPort : public Port { bool _input_active; bool _always_parse; bool _trace_on; - - /* Naming this is tricky. AsyncMIDIPort inherits (for now, aug 2013) from - * both MIDI::Port, which has _parser, and this (ARDOUR::MidiPort). We - * need parsing support in this object, independently of what the - * MIDI::Port/AsyncMIDIPort stuff does. Rather than risk errors coming - * from not explicitly naming which _parser we want, we will call this - * _self_parser for now. - * - * Ultimately, MIDI::Port should probably go away or be fully integrated - * into this object, somehow. - */ + MidiFilter inbound_midi_filter; + boost::shared_ptr<MidiPort> _shadow_port; + MidiFilter shadow_midi_filter; + + /* Naming this is tricky. AsyncMIDIPort inherits (for now, aug 2013) from + * both MIDI::Port, which has _parser, and this (ARDOUR::MidiPort). We + * need parsing support in this object, independently of what the + * MIDI::Port/AsyncMIDIPort stuff does. Rather than risk errors coming + * from not explicitly naming which _parser we want, we will call this + * _self_parser for now. + * + * Ultimately, MIDI::Port should probably go away or be fully integrated + * into this object, somehow. + */ MIDI::Parser _self_parser; diff --git a/libs/ardour/async_midi_port.cc b/libs/ardour/async_midi_port.cc index c27a91f006..eee585fd96 100644 --- a/libs/ardour/async_midi_port.cc +++ b/libs/ardour/async_midi_port.cc @@ -146,15 +146,6 @@ AsyncMIDIPort::cycle_start (MIDI::pframes_t nframes) _xthread.wakeup (); } - if (inbound_midi_filter) { - inbound_midi_filter (mb, mb); - } - - if (_shadow_port) { - if (shadow_midi_filter (mb, _shadow_port->get_midi_buffer (nframes))) { - _shadow_port->flush_buffers (nframes); - } - } } } @@ -351,32 +342,3 @@ AsyncMIDIPort::is_process_thread() return pthread_equal (pthread_self(), _process_thread); } -int -AsyncMIDIPort::add_shadow_port (string const & name, MidiFilter mf) -{ - if (!ARDOUR::Port::receives_input()) { - return -1; - } - - if (_shadow_port) { - return -2; - } - - shadow_midi_filter = mf; - - /* shadow port is not async. */ - - if (!(_shadow_port = boost::dynamic_pointer_cast<MidiPort> (AudioEngine::instance()->register_output_port (DataType::MIDI, name, false, PortFlags (Shadow|IsTerminal))))) { - return -3; - } - - /* forward on our port latency to the shadow port. - - XXX: need to capture latency changes and forward them too. - */ - - LatencyRange latency = private_latency_range (false); - _shadow_port->set_private_latency_range (latency, false); - - return 0; -} diff --git a/libs/ardour/midi_port.cc b/libs/ardour/midi_port.cc index 53e25fee19..02a86bfb8f 100644 --- a/libs/ardour/midi_port.cc +++ b/libs/ardour/midi_port.cc @@ -81,6 +81,19 @@ MidiPort::cycle_start (pframes_t nframes) } } } + + if (inbound_midi_filter) { + MidiBuffer& mb (get_midi_buffer (nframes)); + inbound_midi_filter (mb, mb); + } + + if (_shadow_port) { + MidiBuffer& mb (get_midi_buffer (nframes)); + if (shadow_midi_filter (mb, _shadow_port->get_midi_buffer (nframes))) { + _shadow_port->flush_buffers (nframes); + } + } + } Buffer& @@ -318,3 +331,31 @@ MidiPort::set_trace_on (bool yn) { _trace_on = yn; } + +int +MidiPort::add_shadow_port (string const & name, MidiFilter mf) +{ + if (!ARDOUR::Port::receives_input()) { + return -1; + } + + if (_shadow_port) { + return -2; + } + + shadow_midi_filter = mf; + + if (!(_shadow_port = boost::dynamic_pointer_cast<MidiPort> (AudioEngine::instance()->register_output_port (DataType::MIDI, name, false, PortFlags (Shadow|IsTerminal))))) { + return -3; + } + + /* forward on our port latency to the shadow port. + + XXX: need to capture latency changes and forward them too. + */ + + LatencyRange latency = private_latency_range (false); + _shadow_port->set_private_latency_range (latency, false); + + return 0; +} |