Be more tolerant to missing values or errors in io_config()
[ardour.git] / libs / ardour / bundle.cc
index f38fe0c42f7234173d1068c2d4e1d39992535104..c27905e2cf4b9ee9a19302e64dc255119c31dc2e 100644 (file)
@@ -23,7 +23,7 @@
 #include "ardour/audioengine.h"
 #include "ardour/port.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace std;
 using namespace ARDOUR;
@@ -205,6 +205,9 @@ Bundle::remove_channel (uint32_t ch)
 
        Glib::Threads::Mutex::Lock lm (_channel_mutex);
        _channel.erase (_channel.begin () + ch);
+
+       lm.release();
+       emit_changed (ConfigurationChanged);
 }
 
 /** Remove all channels */
@@ -214,6 +217,9 @@ Bundle::remove_channels ()
        Glib::Threads::Mutex::Lock lm (_channel_mutex);
 
        _channel.clear ();
+
+       lm.release();
+       emit_changed (ConfigurationChanged);
 }
 
 /** @param p Port name.
@@ -437,27 +443,26 @@ Bundle::connected_to (boost::shared_ptr<Bundle> other, AudioEngine & engine)
        return true;
 }
 
-/** This must not be called in code executed as a response to a JACK event,
- *  as it uses jack_port_get_all_connections().
+/** This must not be called in code executed as a response to a backend event,
+ *  as it uses the backend port_get_all_connections().
  *  @return true if any of this bundle's channels are connected to anything.
  */
 bool
 Bundle::connected_to_anything (AudioEngine& engine)
 {
+       PortManager& pm (engine);
+
        for (uint32_t i = 0; i < nchannels().n_total(); ++i) {
                Bundle::PortList const & ports = channel_ports (i);
 
                for (uint32_t j = 0; j < ports.size(); ++j) {
-                       /* ports[j] may not be an Ardour port, so use JACK directly
+
+                       /* ports[j] may not be an Ardour port, so use the port manager directly
                           rather than doing it with Port.
                        */
-                       jack_port_t* jp = jack_port_by_name (engine.jack(), ports[j].c_str());
-                       if (jp) {
-                               const char ** c = jack_port_get_all_connections (engine.jack(), jp);
-                               if (c) {
-                                       jack_free (c);
-                                       return true;
-                               }
+
+                       if (pm.connected (ports[j])) {
+                               return true;
                        }
                }
        }
@@ -563,7 +568,7 @@ Bundle::type_channel_to_overall (DataType t, uint32_t c) const
        if (t == DataType::NIL) {
                return c;
        }
-       
+
        Glib::Threads::Mutex::Lock lm (_channel_mutex);
 
        vector<Channel>::const_iterator i = _channel.begin ();
@@ -586,7 +591,7 @@ Bundle::type_channel_to_overall (DataType t, uint32_t c) const
                ++o;
        }
 
-       /* NOTREACHED */
+       abort(); /* NOTREACHED */
        return -1;
 }
 
@@ -597,11 +602,11 @@ Bundle::overall_channel_to_type (DataType t, uint32_t c) const
        if (t == DataType::NIL) {
                return c;
        }
-       
+
        Glib::Threads::Mutex::Lock lm (_channel_mutex);
 
        uint32_t s = 0;
-       
+
        vector<Channel>::const_iterator i = _channel.begin ();
        for (uint32_t j = 0; j < c; ++j) {
                if (i->type == t) {