X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fsurfaces%2Fmackie%2Fsurface_port.cc;h=ddc5a7b037e0fbd0deebbb0f56b33e8578b45047;hb=cf52d6e4b40111eb04b244ec054055a4ec15dbe0;hp=013a0019c7e797ef9982df56412a07cd8a7fbc94;hpb=52003be3695ab703b936163d7284e208790d5363;p=ardour.git diff --git a/libs/surfaces/mackie/surface_port.cc b/libs/surfaces/mackie/surface_port.cc index 013a0019c7..ddc5a7b037 100644 --- a/libs/surfaces/mackie/surface_port.cc +++ b/libs/surfaces/mackie/surface_port.cc @@ -41,12 +41,13 @@ #include "surface.h" #include "surface_port.h" -#include "i18n.h" +#include "pbd/i18n.h" using namespace std; -using namespace Mackie; using namespace PBD; using namespace ARDOUR; +using namespace ArdourSurface; +using namespace Mackie; SurfacePort::SurfacePort (Surface& s) : _surface (&s) @@ -56,9 +57,25 @@ SurfacePort::SurfacePort (Surface& s) _output_port = _input_port; } else { - - _async_in = AudioEngine::instance()->register_input_port (DataType::MIDI, string_compose (_("%1 in"), _surface->name()), true); - _async_out = AudioEngine::instance()->register_output_port (DataType::MIDI, string_compose (_("%1 out"), _surface->name()), true); + + string in_name; + string out_name; + + if (_surface->mcp().device_info().extenders() > 0) { + if (_surface->number() == _surface->mcp().device_info().master_position()) { + in_name = X_("mackie control in"); + out_name = X_("mackie control out"); + } else { + in_name = string_compose (X_("mackie control in ext %1"), (_surface->number() + 1)); + out_name = string_compose (X_("mackie control out ext %1"), _surface->number() + 1); + } + } else { + in_name = X_("mackie control in"); + out_name = X_("mackie control out"); + } + + _async_in = AudioEngine::instance()->register_input_port (DataType::MIDI, in_name, true); + _async_out = AudioEngine::instance()->register_output_port (DataType::MIDI, out_name, true); if (_async_in == 0 || _async_out == 0) { throw failed_constructor(); @@ -73,15 +90,17 @@ SurfacePort::~SurfacePort() { if (dynamic_cast(_input_port)) { delete _input_port; + _input_port = 0; } else { - if (_async_in) { + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("unregistering input port %1\n", _async_in->name())); AudioEngine::instance()->unregister_port (_async_in); _async_in.reset ((ARDOUR::Port*) 0); } - + if (_async_out) { - _output_port->drain (10000); + _output_port->drain (10000, 250000); + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("unregistering output port %1\n", _async_out->name())); AudioEngine::instance()->unregister_port (_async_out); _async_out.reset ((ARDOUR::Port*) 0); } @@ -103,7 +122,7 @@ SurfacePort::get_state () child = new XMLNode (X_("Input")); child->add_child_nocopy (_async_in->get_state()); node->add_child_nocopy (*child); - + child = new XMLNode (X_("Output")); child->add_child_nocopy (_async_out->get_state()); @@ -138,14 +157,33 @@ SurfacePort::set_state (const XMLNode& node, int version) return 0; } +void +SurfacePort::reconnect () +{ + _async_out->reconnect (); + _async_in->reconnect (); +} + +std::string +SurfacePort::input_name () const +{ + return _async_in->name(); +} + +std::string +SurfacePort::output_name () const +{ + return _async_out->name(); +} + // wrapper for one day when strerror_r is working properly string fetch_errmsg (int error_number) { char * msg = strerror (error_number); return msg; } - -int + +int SurfacePort::write (const MidiByteArray & mba) { if (mba.empty()) { @@ -158,7 +196,7 @@ SurfacePort::write (const MidiByteArray & mba) if (mba[0] != 0xf0 && mba.size() > 3) { std::cerr << "TOO LONG WRITE: " << mba << std::endl; } - + /* this call relies on std::vector using contiguous storage. not * actually guaranteed by the standard, but way, way beyond likely. */ @@ -184,7 +222,7 @@ SurfacePort::write (const MidiByteArray & mba) return 0; } -ostream & +ostream & Mackie::operator << (ostream & os, const SurfacePort & port) { os << "{ "; @@ -193,4 +231,3 @@ Mackie::operator << (ostream & os, const SurfacePort & port) os << " }"; return os; } -