+/** This must not be called in code executed as a response to a JACK event,
+ * as it uses jack_port_get_all_connections().
+ * @return true if any of this bundle's channels are connected to anything.
+ */
+bool
+Bundle::connected_to_anything (AudioEngine& 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
+ 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;
+ }
+ }
+ }
+ }
+
+ return false;
+}
+