diff options
author | Carl Hetherington <carl@carlh.net> | 2009-01-24 15:21:22 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2009-01-24 15:21:22 +0000 |
commit | 4cd47cf253ada6218c13b9a4127834cf4a26ce3d (patch) | |
tree | 78c2ba010eb4ac09b1d42443bb05ef383730b41c /gtk2_ardour/port_group.cc | |
parent | df6680f45c4fc411364768ce75830ce0ee2085a2 (diff) |
Gather all ardour: ports so that a few more things are found to put in the port matrix.
git-svn-id: svn://localhost/ardour2/branches/3.0@4439 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/port_group.cc')
-rw-r--r-- | gtk2_ardour/port_group.cc | 57 |
1 files changed, 35 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) { |