MCP: various fixes, plus removal of ui_bind() (just for mackie code)
[ardour.git] / libs / surfaces / mackie / mackie_control_protocol.cc
index 6817564244c9c1d86099f90d1837ac381006458a..f93379f3e77f076df18c03b033b3b0c16b7278d9 100644 (file)
@@ -78,8 +78,6 @@ using namespace Glib;
 
 #include "pbd/abstract_ui.cc" // instantiate template
 
-#define ui_bind(f, ...) boost::protect (boost::bind (f, __VA_ARGS__))
-
 const int MackieControlProtocol::MODIFIER_OPTION = 0x1;
 const int MackieControlProtocol::MODIFIER_CONTROL = 0x2;
 const int MackieControlProtocol::MODIFIER_SHIFT = 0x4;
@@ -115,7 +113,7 @@ MackieControlProtocol::MackieControlProtocol (Session& session)
        set_device (Config->get_mackie_device_name());
        set_profile (Config->get_mackie_device_profile());
        
-       TrackSelectionChanged.connect (gui_connections, MISSING_INVALIDATOR, ui_bind (&MackieControlProtocol::gui_track_selection_changed, this, _1), this);
+       TrackSelectionChanged.connect (gui_connections, MISSING_INVALIDATOR, boost::bind (&MackieControlProtocol::gui_track_selection_changed, this, _1), this);
 
        _instance = this;
 
@@ -497,24 +495,24 @@ void
 MackieControlProtocol::connect_session_signals()
 {
        // receive routes added
-       session->RouteAdded.connect(session_connections, MISSING_INVALIDATOR, ui_bind (&MackieControlProtocol::notify_route_added, this, _1), this);
+       session->RouteAdded.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&MackieControlProtocol::notify_route_added, this, _1), this);
        // receive record state toggled
-       session->RecordStateChanged.connect(session_connections, MISSING_INVALIDATOR, ui_bind (&MackieControlProtocol::notify_record_state_changed, this), this);
+       session->RecordStateChanged.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&MackieControlProtocol::notify_record_state_changed, this), this);
        // receive transport state changed
-       session->TransportStateChange.connect(session_connections, MISSING_INVALIDATOR, ui_bind (&MackieControlProtocol::notify_transport_state_changed, this), this);
-       session->TransportLooped.connect (session_connections, MISSING_INVALIDATOR, ui_bind (&MackieControlProtocol::notify_loop_state_changed, this), this);
+       session->TransportStateChange.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&MackieControlProtocol::notify_transport_state_changed, this), this);
+       session->TransportLooped.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&MackieControlProtocol::notify_loop_state_changed, this), this);
        // receive punch-in and punch-out
-       Config->ParameterChanged.connect(session_connections, MISSING_INVALIDATOR, ui_bind (&MackieControlProtocol::notify_parameter_changed, this, _1), this);
-       session->config.ParameterChanged.connect (session_connections, MISSING_INVALIDATOR, ui_bind (&MackieControlProtocol::notify_parameter_changed, this, _1), this);
+       Config->ParameterChanged.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&MackieControlProtocol::notify_parameter_changed, this, _1), this);
+       session->config.ParameterChanged.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&MackieControlProtocol::notify_parameter_changed, this, _1), this);
        // receive rude solo changed
-       session->SoloActive.connect(session_connections, MISSING_INVALIDATOR, ui_bind (&MackieControlProtocol::notify_solo_active_changed, this, _1), this);
+       session->SoloActive.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&MackieControlProtocol::notify_solo_active_changed, this, _1), this);
 
        // make sure remote id changed signals reach here
        // see also notify_route_added
        Sorted sorted = get_sorted_routes();
 
        for (Sorted::iterator it = sorted.begin(); it != sorted.end(); ++it) {
-               (*it)->RemoteControlIDChanged.connect (route_connections, MISSING_INVALIDATOR, ui_bind(&MackieControlProtocol::notify_remote_id_changed, this), this);
+               (*it)->RemoteControlIDChanged.connect (route_connections, MISSING_INVALIDATOR, boost::bind (&MackieControlProtocol::notify_remote_id_changed, this), this);
        }
 }
 
@@ -544,6 +542,11 @@ MackieControlProtocol::set_device (const string& device_name)
                return;
        }
        
+       if (_active) {
+               clear_ports ();
+               surfaces.clear ();      
+       }
+
        _device_info = d->second;
 
        /* store it away in a global location */
@@ -551,8 +554,6 @@ MackieControlProtocol::set_device (const string& device_name)
        Config->set_mackie_device_name (device_name);
 
        if (_active) {
-               clear_ports ();
-               surfaces.clear ();
                create_surfaces ();
                switch_banks (0, true);
        }
@@ -794,7 +795,7 @@ MackieControlProtocol::notify_route_added (ARDOUR::RouteList & rl)
        typedef ARDOUR::RouteList ARS;
 
        for (ARS::iterator it = rl.begin(); it != rl.end(); ++it) {
-               (*it)->RemoteControlIDChanged.connect (route_connections, MISSING_INVALIDATOR, ui_bind (&MackieControlProtocol::notify_remote_id_changed, this), this);
+               (*it)->RemoteControlIDChanged.connect (route_connections, MISSING_INVALIDATOR, boost::bind (&MackieControlProtocol::notify_remote_id_changed, this), this);
        }
 }