move shadow port stuff from AsyncMIDIPort to MidiPort, where it belongs
This commit is contained in:
parent
67620c353f
commit
d1c024f4f9
|
@ -73,11 +73,6 @@ class LIBARDOUR_API AsyncMIDIPort : public ARDOUR::MidiPort, public MIDI::Port {
|
||||||
int selectable() const { return -1; }
|
int selectable() const { return -1; }
|
||||||
void set_timer (boost::function<framecnt_t (void)>&);
|
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 void set_process_thread (pthread_t);
|
||||||
static pthread_t get_process_thread () { return _process_thread; }
|
static pthread_t get_process_thread () { return _process_thread; }
|
||||||
static bool is_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);
|
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;
|
static pthread_t _process_thread;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,11 @@ class LIBARDOUR_API MidiPort : public Port {
|
||||||
void set_always_parse (bool yn);
|
void set_always_parse (bool yn);
|
||||||
void set_trace_on (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; }
|
MIDI::Parser& self_parser() { return _self_parser; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -72,6 +77,9 @@ class LIBARDOUR_API MidiPort : public Port {
|
||||||
bool _input_active;
|
bool _input_active;
|
||||||
bool _always_parse;
|
bool _always_parse;
|
||||||
bool _trace_on;
|
bool _trace_on;
|
||||||
|
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
|
/* Naming this is tricky. AsyncMIDIPort inherits (for now, aug 2013) from
|
||||||
* both MIDI::Port, which has _parser, and this (ARDOUR::MidiPort). We
|
* both MIDI::Port, which has _parser, and this (ARDOUR::MidiPort). We
|
||||||
|
|
|
@ -146,15 +146,6 @@ AsyncMIDIPort::cycle_start (MIDI::pframes_t nframes)
|
||||||
_xthread.wakeup ();
|
_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);
|
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;
|
|
||||||
}
|
|
||||||
|
|
|
@ -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&
|
Buffer&
|
||||||
|
@ -318,3 +331,31 @@ MidiPort::set_trace_on (bool yn)
|
||||||
{
|
{
|
||||||
_trace_on = 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;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user