+ uint32_t cchns;
+ uint32_t mchns;
+ AutoConnectOption iconnect;
+ AutoConnectOption oconnect;
+ uint32_t nphysin;
+ uint32_t nphysout;
+
+ if (Profile->get_sae()) {
+
+ cchns = 0;
+ mchns = 2;
+ iconnect = AutoConnectPhysical;
+ oconnect = AutoConnectMaster;
+ nphysin = 0; // use all available
+ nphysout = 0; // use all available
+
+ } else {
+
+ /* get settings from advanced section of NSD */
+
+ if (_startup->create_control_bus()) {
+ cchns = (uint32_t) _startup->control_channel_count();
+ } else {
+ cchns = 0;
+ }
+
+ if (_startup->create_master_bus()) {
+ mchns = (uint32_t) _startup->master_channel_count();
+ } else {
+ mchns = 0;
+ }
+
+ if (_startup->connect_inputs()) {
+ iconnect = AutoConnectPhysical;
+ } else {
+ iconnect = AutoConnectOption (0);
+ }
+
+ /// @todo some minor tweaks.
+
+ if (_startup->connect_outs_to_master()) {
+ oconnect = AutoConnectMaster;
+ } else if (_startup->connect_outs_to_physical()) {
+ oconnect = AutoConnectPhysical;
+ } else {
+ oconnect = AutoConnectOption (0);
+ }
+
+ nphysin = (uint32_t) _startup->input_limit_count();
+ nphysout = (uint32_t) _startup->output_limit_count();
+ }
+
+ if (build_session (session_path,
+ session_name,
+ cchns,
+ mchns,
+ iconnect,
+ oconnect,
+ nphysin,
+ nphysout,
+ engine->frame_rate() * 60 * 5)) {
+
+ return -1;
+ }
+
+ return 0;
+}
+
+void
+ARDOUR_UI::idle_load (const Glib::ustring& path)
+{
+ if (session) {
+ if (Glib::file_test (path, Glib::FILE_TEST_IS_DIR)) {
+ /* /path/to/foo => /path/to/foo, foo */
+ load_session (path, basename_nosuffix (path));
+ } else {
+ /* /path/to/foo/foo.ardour => /path/to/foo, foo */
+ load_session (Glib::path_get_dirname (path), basename_nosuffix (path));
+ }
+ } else {
+
+ ARDOUR_COMMAND_LINE::session_name = path;
+
+ /*
+ * new_session_dialog doens't exist in A3
+ * Try to remove all references to it to
+ * see if it will compile. NOTE: this will
+ * likely cause a runtime issue is my somewhat
+ * uneducated guess.
+ */
+
+ //if (new_session_dialog) {
+
+
+ /* make it break out of Dialog::run() and
+ start again.
+ */
+
+ //new_session_dialog->response (1);
+ //}
+ }
+}
+
+void
+ARDOUR_UI::end_loading_messages ()
+{
+ // hide_splash ();
+}
+
+void
+ARDOUR_UI::loading_message (const std::string& /*msg*/)
+{
+ // show_splash ();
+ // splash->message (msg);
+ flush_pending ();
+}
+
+int
+ARDOUR_UI::get_session_parameters (bool should_be_new)
+{
+ Glib::ustring session_name;
+ Glib::ustring session_path;
+ Glib::ustring template_name;
+ int ret = -1;
+ bool likely_new = false;
+
+ while (ret != 0) {
+
+ if (!should_be_new && !ARDOUR_COMMAND_LINE::session_name.empty()) {
+
+ /* if they named a specific statefile, use it, otherwise they are
+ just giving a session folder, and we want to use it as is
+ to find the session.
+ */
+
+ if (ARDOUR_COMMAND_LINE::session_name.find (statefile_suffix) != string::npos) {
+ session_path = Glib::path_get_dirname (ARDOUR_COMMAND_LINE::session_name);
+ } else {
+ session_path = ARDOUR_COMMAND_LINE::session_name;
+ }
+
+ session_name = Glib::path_get_basename (ARDOUR_COMMAND_LINE::session_name);
+
+ } else {
+
+ run_startup (should_be_new);
+
+ /* if we run the startup dialog again, offer more than just "new session" */
+
+ should_be_new = false;
+
+ session_name = _startup->session_name (likely_new);
+
+ /* this shouldn't happen, but we catch it just in case it does */
+
+ if (session_name.empty()) {
+ break;
+ }
+ if (_startup->use_session_template()) {
+ template_name = _startup->session_template_name();
+ _session_is_new = true;
+ }
+
+
+ if (session_name[0] == '/' ||
+ (session_name.length() > 2 && session_name[0] == '.' && session_name[1] == '/') ||
+ (session_name.length() > 3 && session_name[0] == '.' && session_name[1] == '.' && session_name[2] == '/')) {
+
+ session_path = Glib::path_get_dirname (session_name);
+ session_name = Glib::path_get_basename (session_name);
+
+ } else {
+
+ session_path = _startup->session_folder();
+ }
+ }
+
+ if (create_engine ()) {
+ break;
+ }
+
+ if (Glib::file_test (session_path, Glib::FileTest (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
+
+ if (likely_new) {
+
+ Glib::ustring existing = Glib::build_filename (session_path, session_name);
+
+ if (!ask_about_loading_existing_session (existing)) {
+ ARDOUR_COMMAND_LINE::session_name = ""; // cancel that
+ continue;
+ }
+ }
+
+ _session_is_new = false;
+
+ } else {
+
+ if (!likely_new) {
+ MessageDialog msg (string_compose (_("There is no existing session at \"%1\""), session_path));
+ msg.run ();
+ ARDOUR_COMMAND_LINE::session_name = ""; // cancel that
+ continue;
+ }
+
+ _session_is_new = true;
+ }
+
+ if (likely_new && template_name.empty()) {
+
+ ret = build_session_from_nsd (session_path, session_name);
+
+ } else {
+
+ ret = load_session (session_path, session_name, template_name);
+ }
+ }
+
+ return ret;
+}
+
+void
+ARDOUR_UI::close_session()
+{
+ if (!check_audioengine()) {
+ return;
+ }
+
+ unload_session (true);
+
+ ARDOUR_COMMAND_LINE::session_name = "";
+ get_session_parameters (false);
+}
+
+int
+ARDOUR_UI::load_session (const Glib::ustring& path, const Glib::ustring& snap_name, Glib::ustring mix_template)
+{
+ Session *new_session;
+ int unload_status;
+ int retval = -1;
+
+ session_loaded = false;
+
+ if (!check_audioengine()) {
+ return -1;
+ }
+
+ unload_status = unload_session ();
+
+ if (unload_status < 0) {
+ goto out;
+ } else if (unload_status > 0) {
+ retval = 0;
+ goto out;