diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2012-04-24 02:28:51 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2012-04-24 02:28:51 +0000 |
commit | 33140f32671576a285d62f529447f941f96313fc (patch) | |
tree | 44faee5b21e3181077d0c22180895fb072432a53 /libs/surfaces/mackie/surface_port.cc | |
parent | 10d37fecc1b54487a5fb0f3652bfb45a5224ef8b (diff) |
add support for IP MIDI (multicast MIDI over IP UDP sockets) to ardour and use it if requested inside MCP code. required renaming the pre-existing MIDI::Port as MIDI:JackMIDIPort - MIDI::Port becomes the base type for both JackMIDIPort and IPMIDIPort
git-svn-id: svn://localhost/ardour2/branches/3.0@12069 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/surfaces/mackie/surface_port.cc')
-rw-r--r-- | libs/surfaces/mackie/surface_port.cc | 65 |
1 files changed, 39 insertions, 26 deletions
diff --git a/libs/surfaces/mackie/surface_port.cc b/libs/surfaces/mackie/surface_port.cc index be080fa44b..645da67b43 100644 --- a/libs/surfaces/mackie/surface_port.cc +++ b/libs/surfaces/mackie/surface_port.cc @@ -25,6 +25,8 @@ #include "midi++/types.h" #include "midi++/port.h" +#include "midi++/jack_midi_port.h" +#include "midi++/ipmidi_port.h" #include "midi++/manager.h" #include "ardour/debug.h" @@ -51,38 +53,49 @@ using namespace PBD; SurfacePort::SurfacePort (Surface& s) : _surface (&s) { - jack_client_t* jack = MackieControlProtocol::instance()->get_session().engine().jack(); - - _input_port = new MIDI::Port (string_compose (_("%1 in"), _surface->name()), MIDI::Port::IsInput, jack); - _output_port =new MIDI::Port (string_compose (_("%1 out"), _surface->name()), MIDI::Port::IsOutput, jack); - - /* MackieControl has its own thread for handling input from the input - * port, and we don't want anything handling output from the output - * port. This stops the Generic MIDI UI event loop in ardour from - * attempting to handle these ports. - */ - - _input_port->set_centrally_parsed (false); - _output_port->set_centrally_parsed (false); - - MIDI::Manager * mm = MIDI::Manager::instance(); - - mm->add_port (_input_port); - mm->add_port (_output_port); + if (_surface->mcp().device_info().uses_ipmidi()) { + _input_port = new MIDI::IPMIDIPort (MIDI::IPMIDIPort::lowest_ipmidi_port_default+_surface->number()); + _output_port = _input_port; + } else { + jack_client_t* jack = MackieControlProtocol::instance()->get_session().engine().jack(); + + _input_port = new MIDI::JackMIDIPort (string_compose (_("%1 in"), _surface->name()), MIDI::Port::IsInput, jack); + _output_port =new MIDI::JackMIDIPort (string_compose (_("%1 out"), _surface->name()), MIDI::Port::IsOutput, jack); + + /* MackieControl has its own thread for handling input from the input + * port, and we don't want anything handling output from the output + * port. This stops the Generic MIDI UI event loop in ardour from + * attempting to handle these ports. + */ + + _input_port->set_centrally_parsed (false); + _output_port->set_centrally_parsed (false); + + MIDI::Manager * mm = MIDI::Manager::instance(); + + mm->add_port (_input_port); + mm->add_port (_output_port); + } } SurfacePort::~SurfacePort() { - MIDI::Manager* mm = MIDI::Manager::instance (); - - if (_input_port) { - mm->remove_port (_input_port); + if (_surface->mcp().device_info().uses_ipmidi()) { delete _input_port; - } + } else { - if (_output_port) { - mm->remove_port (_output_port); - delete _output_port; + MIDI::Manager* mm = MIDI::Manager::instance (); + + if (_input_port) { + mm->remove_port (_input_port); + delete _input_port; + } + + if (_output_port) { + _output_port->drain (10000); + mm->remove_port (_output_port); + delete _output_port; + } } } |