summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk2_ardour/port_group.cc57
-rw-r--r--gtk2_ardour/port_group.h3
-rw-r--r--libs/ardour/ardour/bundle.h1
-rw-r--r--libs/ardour/bundle.cc17
4 files changed, 56 insertions, 22 deletions
diff --git a/gtk2_ardour/port_group.cc b/gtk2_ardour/port_group.cc
index 70fd5a1b84..accab1d183 100644
--- a/gtk2_ardour/port_group.cc
+++ b/gtk2_ardour/port_group.cc
@@ -57,6 +57,25 @@ PortGroup::clear ()
ports.clear ();
}
+bool
+PortGroup::has_port (std::string const& p) const
+{
+ for (vector<boost::shared_ptr<ARDOUR::Bundle> >::const_iterator i = bundles.begin(); i != bundles.end(); ++i) {
+ if ((*i)->offers_port_alone (p)) {
+ return true;
+ }
+ }
+
+ for (vector<std::string>::const_iterator i = ports.begin(); i != ports.end(); ++i) {
+ if (*i == p) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
/** PortGroupUI constructor.
* @param m PortMatrix to work for.
* @Param g PortGroup to represent.
@@ -159,9 +178,7 @@ PortGroupList::refresh ()
/* XXX: inserts, sends, plugin inserts? */
- /* Now we need to find the non-ardour ports; we do this by first
- finding all the ports that we can connect to.
- */
+ /* Now find all other ports that we haven't thought of yet */
const char **ports = _session.engine().get_ports ("", _type.to_jack_type(), _offer_inputs ?
JackPortIsInput : JackPortIsOutput);
@@ -174,31 +191,20 @@ PortGroupList::refresh ()
client_matching_string += ':';
while (ports[n]) {
+
std::string const p = ports[n];
- if (p.substr(0, strlen ("system:")) == "system:" || p.substr (0, strlen ("alsa_pcm:")) == "alsa_pcm:") {
- /* system: or alsa_pcm: prefix */
-
- /* see if this port is already in one of the system: bundles */
- std::vector<boost::shared_ptr<ARDOUR::Bundle> >::iterator i = _system.bundles.begin();
- while (i != _system.bundles.end()) {
- if ((*i)->uses_port (p)) {
- break;
- }
- ++i;
- }
-
- if (i == _system.bundles.end()) {
- /* it's not already in there, so add it */
+ if (!_system.has_port(p) && !_buss.has_port(p) && !_track.has_port(p) && !_other.has_port(p)) {
+
+ if (port_has_prefix (p, "system:") ||
+ port_has_prefix (p, "alsa_pcm") ||
+ port_has_prefix (p, "ardour:")) {
_system.add_port (p);
- }
- } else {
- if (p.substr(0, client_matching_string.length()) != client_matching_string) {
- /* other (non-ardour) prefix */
+ } else {
_other.add_port (p);
}
}
-
+
++n;
}
@@ -211,6 +217,13 @@ PortGroupList::refresh ()
push_back (&_other);
}
+bool
+PortGroupList::port_has_prefix (const std::string& n, const std::string& p) const
+{
+ return n.substr (0, p.length()) == p;
+}
+
+
void
PortGroupList::set_type (ARDOUR::DataType t)
{
diff --git a/gtk2_ardour/port_group.h b/gtk2_ardour/port_group.h
index d2136d6f5e..a5b5b109c4 100644
--- a/gtk2_ardour/port_group.h
+++ b/gtk2_ardour/port_group.h
@@ -64,6 +64,8 @@ public:
VisibilityChanged ();
}
+ bool has_port (std::string const &) const;
+
sigc::signal<void> VisibilityChanged;
private:
@@ -112,6 +114,7 @@ class PortGroupList : public std::list<PortGroup*>, public sigc::trackable
private:
void maybe_add_session_bundle (boost::shared_ptr<ARDOUR::Bundle>);
+ bool port_has_prefix (std::string const &, std::string const &) const;
std::string common_prefix (std::vector<std::string> const &) const;
void visibility_changed ();
diff --git a/libs/ardour/ardour/bundle.h b/libs/ardour/ardour/bundle.h
index 8b1af39e75..f9971ddf15 100644
--- a/libs/ardour/ardour/bundle.h
+++ b/libs/ardour/ardour/bundle.h
@@ -90,6 +90,7 @@ class Bundle : public sigc::trackable
void remove_port_from_channel (uint32_t, std::string);
bool port_attached_to_channel (uint32_t, std::string);
bool uses_port (std::string) const;
+ bool offers_port_alone (std::string) const;
void remove_channel (uint32_t);
void remove_channels ();
diff --git a/libs/ardour/bundle.cc b/libs/ardour/bundle.cc
index 70800b06eb..53fc2f1930 100644
--- a/libs/ardour/bundle.cc
+++ b/libs/ardour/bundle.cc
@@ -173,6 +173,23 @@ Bundle::uses_port (std::string p) const
return false;
}
+/** @param p Port name.
+ * @return true if this bundle offers this port on its own on a channel.
+ */
+bool
+Bundle::offers_port_alone (std::string p) const
+{
+ Glib::Mutex::Lock lm (_channel_mutex);
+
+ for (std::vector<Channel>::const_iterator i = _channel.begin(); i != _channel.end(); ++i) {
+ if (i->ports.size() == 1 && i->ports[0] == p) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
std::string
Bundle::channel_name (uint32_t ch) const
{