Update Mackie surface state when something is connected to its output port (#3887).
authorCarl Hetherington <carl@carlh.net>
Mon, 26 Sep 2011 22:22:21 +0000 (22:22 +0000)
committerCarl Hetherington <carl@carlh.net>
Mon, 26 Sep 2011 22:22:21 +0000 (22:22 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@10135 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/mixer_strip.cc
libs/ardour/ardour/audioengine.h
libs/ardour/audioengine.cc
libs/surfaces/mackie/mackie_control_protocol.cc
libs/surfaces/mackie/mackie_control_protocol.h

index e4d9b4058a596f8043d03d9977a95889ff78e1b4..7012ad61f5060349fa5694fe7f0b6913be77dde0 100644 (file)
@@ -334,7 +334,7 @@ MixerStrip::init ()
        SwitchIO.connect (sigc::mem_fun (*this, &MixerStrip::switch_io));
 
        AudioEngine::instance()->PortConnectedOrDisconnected.connect (
-               *this, invalidator (*this), boost::bind (&MixerStrip::port_connected_or_disconnected, this, _1, _2), gui_context ()
+               *this, invalidator (*this), boost::bind (&MixerStrip::port_connected_or_disconnected, this, _1, _3), gui_context ()
                );
 }
 
index ee2276a3bf19cdace94b9e2cc1cda0d3090baee6..4d7d93510bd982f0e3a999eb8513c7a7191a5641 100644 (file)
@@ -249,9 +249,10 @@ _     the regular process() call to session->process() is not made.
 
        /** Emitted if a JACK port is connected or disconnected.
         *  The Port parameters are the ports being connected / disconnected, or 0 if they are not known to Ardour.
+        *  The std::string parameters are the (long) port names.
         *  The bool parameter is true if ports were connected, or false for disconnected.
         */
-       PBD::Signal3<void, Port *, Port *, bool> PortConnectedOrDisconnected;
+       PBD::Signal5<void, Port *, std::string, Port *, std::string, bool> PortConnectedOrDisconnected;
 
        std::string make_port_name_relative (std::string) const;
        std::string make_port_name_non_relative (std::string) const;
index 6420b9247df8b5f1e8c36321550e55848da37bb2..47efcf5f714a32a09b8afa86d86b15efc7a61f95 100644 (file)
@@ -402,7 +402,11 @@ AudioEngine::_connect_callback (jack_port_id_t id_a, jack_port_id_t id_b, int co
                ++i;
        }
 
-       ae->PortConnectedOrDisconnected (port_a, port_b, conn == 0 ? false : true); /* EMIT SIGNAL */
+       ae->PortConnectedOrDisconnected (
+               port_a, jack_port_name (jack_port_a),
+               port_b, jack_port_name (jack_port_b),
+               conn == 0 ? false : true
+               ); /* EMIT SIGNAL */
 }
 
 void
index 05d1fa3de201e1f9e4f67ab8b1b435af817db308..d28dcc4f149342bf35ca42d749d7d503a20754ed 100644 (file)
@@ -86,6 +86,11 @@ MackieControlProtocol::MackieControlProtocol (Session& session)
        , _gui (0)
 {
        DEBUG_TRACE (DEBUG::MackieControl, "MackieControlProtocol::MackieControlProtocol\n");
+
+       AudioEngine::instance()->PortConnectedOrDisconnected.connect (
+               audio_engine_connections, MISSING_INVALIDATOR, ui_bind (&MackieControlProtocol::port_connected_or_disconnected, this, _2, _4, _5),
+               midi_ui_context ()
+               );
 }
 
 MackieControlProtocol::~MackieControlProtocol()
@@ -1742,3 +1747,31 @@ MackieControlProtocol::bundles ()
        b.push_back (_output_bundle);
        return b;
 }
+
+void
+MackieControlProtocol::port_connected_or_disconnected (string a, string b, bool connected)
+{
+       /* If something is connected to one of our output ports, send MIDI to update the surface
+          to whatever state it should have.
+       */
+
+       if (!connected) {
+               return;
+       }
+
+       MackiePorts::const_iterator i = _ports.begin();
+       while (i != _ports.end()) {
+
+               string const n = AudioEngine::instance()->make_port_name_non_relative ((*i)->output_port().name ());
+
+               if (a == n || b == n) {
+                       break;
+               }
+
+               ++i;
+       }
+
+       if (i != _ports.end ()) {
+               update_surface ();
+       }
+}
index 05308dbd63ebe3cdbece578bf5dc860917706f2e..beae92651878a63dd6287ce646da4d07475b027f 100644 (file)
@@ -307,6 +307,9 @@ class MackieControlProtocol
        Mackie::Strip & master_strip();
 
   private:
+
+       void port_connected_or_disconnected (std::string, std::string, bool);
+       
        boost::shared_ptr<Mackie::RouteSignal> master_route_signal;
        
        static const char * default_port_name;
@@ -323,7 +326,8 @@ class MackieControlProtocol
        
        /// protects the port list
        Glib::Mutex update_mutex;
-  
+
+       PBD::ScopedConnectionList audio_engine_connections;
        PBD::ScopedConnectionList session_connections;
        PBD::ScopedConnectionList port_connections;
        PBD::ScopedConnectionList route_connections;