remove unused and useless stuff relating to bundles inside Mackie::Strip
[ardour.git] / libs / surfaces / mackie / surface.cc
index 5551c5d0de6bed741c78d52d039a409b836bf0ab..020b389ad4a48bec5ff58cee0324b2ed33d4e148 100644 (file)
@@ -92,6 +92,7 @@ Surface::Surface (MackieControlProtocol& mcp, const std::string& device_name, ui
        , _master_fader (0)
        , _last_master_gain_written (-0.0f)
        , connection_state (0)
+       , input_source (0)
 {
        DEBUG_TRACE (DEBUG::MackieControl, "Surface::Surface init\n");
 
@@ -124,10 +125,20 @@ Surface::Surface (MackieControlProtocol& mcp, const std::string& device_name, ui
                DEBUG_TRACE (DEBUG::MackieControl, "init_strips done\n");
        }
 
-       /*
-        */
+       if (!_mcp.device_info().uses_ipmidi()) {
+               ARDOUR::AudioEngine::instance()->PortConnectedOrDisconnected.connect (port_connection, MISSING_INVALIDATOR, boost::bind (&Surface::connection_handler, this, _1, _2, _3, _4, _5), &_mcp);
+       } else {
+               /* ipMIDI port already exists, we can just assume that we're
+                * connected.
+                *
+                * If the user still hasn't connected the ipMIDI surface and/or
+                * turned it on, then they have to press "Discover Mackie
+                * Devices" in the GUI at the right time.
+                */
 
-       ARDOUR::AudioEngine::instance()->PortConnectedOrDisconnected.connect (port_connection, MISSING_INVALIDATOR, boost::bind (&Surface::connection_handler, this, _1, _2, _3, _4, _5), &_mcp);
+               connection_state |= (InputConnected|OutputConnected);
+               connected ();
+       }
 
        connect_to_signals ();
 
@@ -150,6 +161,13 @@ Surface::~Surface ()
                delete *it;
        }
 
+       port_connection.disconnect ();
+
+       if (input_source) {
+               g_source_destroy (input_source);
+               input_source = 0;
+       }
+
        delete _jog_wheel;
        delete _port;
 
@@ -159,6 +177,10 @@ Surface::~Surface ()
 void
 Surface::connection_handler (boost::weak_ptr<ARDOUR::Port>, std::string name1, boost::weak_ptr<ARDOUR::Port>, std::string name2, bool yn)
 {
+       if (!_port) {
+               return;
+       }
+
        string ni = ARDOUR::AudioEngine::instance()->make_port_name_non_relative (_port->input_name());
        string no = ARDOUR::AudioEngine::instance()->make_port_name_non_relative (_port->output_name());