- if (!system->has_port(p) && !bus->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:")) {
- extra_system.push_back (p);
- } else {
- extra_other.push_back (p);
+ std::vector<std::string> extra_system[DataType::num_types];
+ std::vector<std::string> extra_other[DataType::num_types];
+
+ string lpn (PROGRAM_NAME);
+ boost::to_lower (lpn);
+ string lpnc = lpn;
+ lpnc += ':';
+
+ vector<string> ports;
+ if (AudioEngine::instance()->get_ports ("", type, inputs ? IsInput : IsOutput, ports) > 0) {
+
+ for (vector<string>::const_iterator s = ports.begin(); s != ports.end(); ) {
+
+ std::string const p = *s;
+
+ if (!system->has_port(p) &&
+ !bus->has_port(p) &&
+ !track->has_port(p) &&
+ !ardour->has_port(p) &&
+ !other->has_port(p)) {
+
+ /* special hack: ignore MIDI ports labelled Midi-Through. these
+ are basically useless and mess things up for default
+ connections.
+ */
+
+ if (p.find ("Midi-Through") != string::npos) {
+ ++s;
+ continue;
+ }
+
+ /* special hack: ignore our monitor inputs (which show up here because
+ we excluded them earlier.
+ */
+
+ string lp = p;
+ boost::to_lower (lp);
+
+ if ((lp.find (N_(":monitor")) != string::npos) &&
+ (lp.find (lpn) != string::npos)) {
+ ++s;
+ continue;
+ }
+
+ /* can't use the audio engine for this as we are looking at non-Ardour ports */
+
+ PortEngine::PortHandle ph = AudioEngine::instance()->port_engine().get_port_by_name (p);
+ if (ph) {
+ DataType t (AudioEngine::instance()->port_engine().port_data_type (ph));
+ if (t != DataType::NIL) {
+ if (port_has_prefix (p, N_("system:")) ||
+ port_has_prefix (p, N_("alsa_pcm")) ||
+ port_has_prefix (p, lpnc)) {
+ extra_system[t].push_back (p);
+ } else {
+ extra_other[t].push_back (p);
+ }
+ }