+ boost::shared_ptr<BundleList> b = session->bundles ();
+
+ for (BundleList::iterator i = b->begin(); i != b->end(); ++i) {
+ if (boost::dynamic_pointer_cast<UserBundle> (*i) && (*i)->ports_are_inputs() == inputs) {
+ system->add_bundle (*i, allow_dups);
+ }
+ }
+
+ /* Only look for non-user bundles if instructed to do so */
+ if (use_session_bundles) {
+ for (BundleList::iterator i = b->begin(); i != b->end(); ++i) {
+ if (boost::dynamic_pointer_cast<UserBundle> (*i) == 0 && (*i)->ports_are_inputs() == inputs) {
+ system->add_bundle (*i, allow_dups);
+ }
+ }
+ }
+
+ /* Ardour stuff */
+
+ if (!inputs) {
+ ardour->add_bundle (session->the_auditioner()->output()->bundle());
+ ardour->add_bundle (session->click_io()->bundle());
+ /* Note: the LTC ports do not have the usual ":audio_out 1" postfix, so
+ * ardour->add_bundle (session->ltc_output_io()->bundle());
+ * won't work
+ */
+ boost::shared_ptr<Bundle> ltc (new Bundle (_("LTC Out"), inputs));
+ ltc->add_channel (_("LTC Out"), DataType::AUDIO, session->engine().make_port_name_non_relative (session->ltc_output_port()->name()));
+ ardour->add_bundle (ltc);
+ } else {
+ boost::shared_ptr<Bundle> ltc (new Bundle (_("LTC In"), inputs));
+ ltc->add_channel (_("LTC In"), DataType::AUDIO, session->engine().make_port_name_non_relative (session->ltc_input_port()->name()));
+ ardour->add_bundle (ltc);
+ }
+
+ /* Ardour's surfaces */
+
+ ControlProtocolManager& m = ControlProtocolManager::instance ();
+ for (list<ControlProtocolInfo*>::iterator i = m.control_protocol_info.begin(); i != m.control_protocol_info.end(); ++i) {
+ if ((*i)->protocol) {
+ list<boost::shared_ptr<Bundle> > b = (*i)->protocol->bundles ();
+ for (list<boost::shared_ptr<Bundle> >::iterator j = b.begin(); j != b.end(); ++j) {
+ if ((*j)->ports_are_inputs() == inputs) {
+ ardour->add_bundle (*j);
+ }
+ }
+ }
+ }
+
+ /* Ardour's sync ports */
+
+ MIDI::Manager* midi_manager = MIDI::Manager::instance ();
+ if (midi_manager && (type == DataType::MIDI || type == DataType::NIL)) {
+ boost::shared_ptr<Bundle> sync (new Bundle (_("Sync"), inputs));
+ MIDI::MachineControl* mmc = midi_manager->mmc ();
+ AudioEngine& ae = session->engine ();
+
+ if (inputs) {
+ sync->add_channel (
+ _("MTC in"), DataType::MIDI, ae.make_port_name_non_relative (midi_manager->mtc_input_port()->name())
+ );
+ sync->add_channel (
+ _("MIDI control in"), DataType::MIDI, ae.make_port_name_non_relative (midi_manager->midi_input_port()->name())
+ );
+ sync->add_channel (
+ _("MIDI clock in"), DataType::MIDI, ae.make_port_name_non_relative (midi_manager->midi_clock_input_port()->name())
+ );
+ sync->add_channel (
+ _("MMC in"), DataType::MIDI, ae.make_port_name_non_relative (mmc->input_port()->name())
+ );
+ } else {
+ sync->add_channel (
+ _("MTC out"), DataType::MIDI, ae.make_port_name_non_relative (midi_manager->mtc_output_port()->name())
+ );
+ sync->add_channel (
+ _("MIDI control out"), DataType::MIDI, ae.make_port_name_non_relative (midi_manager->midi_output_port()->name())
+ );
+ sync->add_channel (
+ _("MIDI clock out"), DataType::MIDI, ae.make_port_name_non_relative (midi_manager->midi_clock_output_port()->name())
+ );
+ sync->add_channel (
+ _("MMC out"), DataType::MIDI, ae.make_port_name_non_relative (mmc->output_port()->name())
+ );
+ }
+
+ ardour->add_bundle (sync);
+ }
+
+ /* Now find all other ports that we haven't thought of yet */
+
+ 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 += ':';
+
+ const char ** ports = 0;
+ if (type == DataType::NIL) {
+ ports = session->engine().get_ports ("", "", inputs ? JackPortIsInput : JackPortIsOutput);
+ } else {
+ ports = session->engine().get_ports ("", type.to_jack_type(), inputs ? JackPortIsInput : JackPortIsOutput);
+ }
+