enough with umpteen "i18n.h" files. Consolidate on pbd/i18n.h
[ardour.git] / libs / surfaces / mackie / surface_port.cc
index 3129b5a1fd4303d1de4280d7ceda78d639fe7057..ddc5a7b037e0fbd0deebbb0f56b33e8578b45047 100644 (file)
@@ -41,7 +41,7 @@
 #include "surface.h"
 #include "surface_port.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace std;
 using namespace PBD;
@@ -58,8 +58,24 @@ SurfacePort::SurfacePort (Surface& s)
 
        } 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();
@@ -83,7 +99,7 @@ SurfacePort::~SurfacePort()
                }
 
                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);
@@ -121,29 +137,45 @@ SurfacePort::set_state (const XMLNode& node, int version)
        if (dynamic_cast<MIDI::IPMIDIPort*>(_input_port)) {
                return 0;
        }
-       // the rest should not be run if the device-name changes outside of a session load.
-       if ( _surface->mcp().session_load()) {
 
-               XMLNode* child;
+       XMLNode* child;
 
-               if ((child = node.child (X_("Input"))) != 0) {
-                       XMLNode* portnode = child->child (Port::state_node_name.c_str());
-                       if (portnode) {
-                               _async_in->set_state (*portnode, version);
-                       }
+       if ((child = node.child (X_("Input"))) != 0) {
+               XMLNode* portnode = child->child (Port::state_node_name.c_str());
+               if (portnode) {
+                       _async_in->set_state (*portnode, version);
                }
+       }
 
-               if ((child = node.child (X_("Output"))) != 0) {
-                       XMLNode* portnode = child->child (Port::state_node_name.c_str());
-                       if (portnode) {
-                               _async_out->set_state (*portnode, version);
-                       }
+       if ((child = node.child (X_("Output"))) != 0) {
+               XMLNode* portnode = child->child (Port::state_node_name.c_str());
+               if (portnode) {
+                       _async_out->set_state (*portnode, 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)
 {
@@ -199,4 +231,3 @@ Mackie::operator <<  (ostream & os, const SurfacePort & port)
        os << " }";
        return os;
 }
-