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
This commit is contained in:
parent
df6680f45c
commit
4cd47cf253
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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 ();
|
||||
|
||||
|
|
|
@ -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 ();
|
||||
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue