2033
ARDOUR_UI::get_session_parameters (Glib::ustring predetermined_path, bool have_engine, bool should_be_new)
2021
ARDOUR_UI::parse_cmdline_path (const Glib::ustring& cmdline_path, Glib::ustring& session_name, Glib::ustring& session_path, bool& existing_session)
2023
existing_session = false;
2025
if (Glib::file_test (cmdline_path, Glib::FILE_TEST_IS_DIR)) {
2026
session_path = cmdline_path;
2027
existing_session = true;
2028
} else if (Glib::file_test (cmdline_path, Glib::FILE_TEST_IS_REGULAR)) {
2029
session_path = Glib::path_get_dirname (string (cmdline_path));
2030
existing_session = true;
2032
/* it doesn't exist, assume the best */
2033
session_path = Glib::path_get_dirname (string (cmdline_path));
2036
session_name = basename_nosuffix (string (cmdline_path));
2040
ARDOUR_UI::load_cmdline_session (const Glib::ustring& session_name, const Glib::ustring& session_path, bool& existing_session)
2042
/* when this is called, the backend audio system must be running */
2044
/* the main idea here is to deal with the fact that a cmdline argument for the session
2045
can be interpreted in different ways - it could be a directory or a file, and before
2046
we load, we need to know both the session directory and the snapshot (statefile) within it
2047
that we are supposed to use.
2050
if (session_name.length() == 0 || session_path.length() == 0) {
2054
if (Glib::file_test (session_path, Glib::FILE_TEST_IS_DIR)) {
2056
Glib::ustring predicted_session_file;
2058
predicted_session_file = session_path;
2059
predicted_session_file += '/';
2060
predicted_session_file += session_name;
2061
predicted_session_file += Session::statefile_suffix();
2063
if (Glib::file_test (predicted_session_file, Glib::FILE_TEST_EXISTS)) {
2064
existing_session = true;
2067
} else if (Glib::file_test (session_path, Glib::FILE_TEST_EXISTS)) {
2069
if (session_path.find (Session::statefile_suffix()) == session_path.length() - 7) {
2070
/* existing .ardour file */
2071
existing_session = true;
2075
existing_session = false;
2078
/* lets just try to load it */
2080
if (create_engine ()) {
2081
backend_audio_error (false, new_session_dialog);
2085
return load_session (session_path, session_name);
2089
ARDOUR_UI::ask_about_loading_existing_session (const Glib::ustring& session_path)
2091
Glib::ustring str = string_compose (_("This session\n%1\nalready exists. Do you want to open it?"), session_path);
2093
MessageDialog msg (str,
2095
Gtk::MESSAGE_WARNING,
2096
Gtk::BUTTONS_YES_NO,
2100
msg.set_name (X_("CleanupDialog"));
2101
msg.set_wmclass (X_("existing_session"), "Ardour");
2102
msg.set_position (Gtk::WIN_POS_MOUSE);
2105
switch (msg.run()) {
2114
ARDOUR_UI::build_session_from_nsd (const Glib::ustring& session_path, const Glib::ustring& session_name)
2119
AutoConnectOption iconnect;
2120
AutoConnectOption oconnect;
2124
if (Profile->get_sae()) {
2128
iconnect = AutoConnectPhysical;
2129
oconnect = AutoConnectMaster;
2130
nphysin = 0; // use all available
2131
nphysout = 0; // use all available
2135
/* get settings from advanced section of NSD */
2137
if (new_session_dialog->create_control_bus()) {
2138
cchns = (uint32_t) new_session_dialog->control_channel_count();
2143
if (new_session_dialog->create_master_bus()) {
2144
mchns = (uint32_t) new_session_dialog->master_channel_count();
2149
if (new_session_dialog->connect_inputs()) {
2150
iconnect = AutoConnectPhysical;
2152
iconnect = AutoConnectOption (0);
2155
/// @todo some minor tweaks.
2157
if (new_session_dialog->connect_outs_to_master()) {
2158
oconnect = AutoConnectMaster;
2159
} else if (new_session_dialog->connect_outs_to_physical()) {
2160
oconnect = AutoConnectPhysical;
2162
oconnect = AutoConnectOption (0);
2165
nphysin = (uint32_t) new_session_dialog->input_limit_count();
2166
nphysout = (uint32_t) new_session_dialog->output_limit_count();
2169
if (build_session (session_path,
2177
engine->frame_rate() * 60 * 5)) {
2186
ARDOUR_UI::end_loading_messages ()
2192
ARDOUR_UI::loading_message (const std::string& msg)
2195
splash->message (msg);
2200
ARDOUR_UI::get_session_parameters (bool backend_audio_is_running, bool should_be_new)
2035
2202
bool existing_session = false;
2036
2203
Glib::ustring session_name;
2037
2204
Glib::ustring session_path;
2038
2205
Glib::ustring template_name;
2040
if (!loading_dialog) {
2041
loading_dialog = new MessageDialog (*new_session_dialog,
2049
2207
int response = Gtk::RESPONSE_NONE;
2051
if (predetermined_path.length()) {
2053
/* before we start, lets see if the given path looks like
2054
an existing ardour session. if it does, skip the
2055
tabs that we don't need
2058
if (Glib::file_test (predetermined_path, Glib::FILE_TEST_IS_DIR)) {
2059
session_path = predetermined_path;
2060
existing_session = true;
2061
} else if (Glib::file_test (predetermined_path, Glib::FILE_TEST_IS_REGULAR)) {
2062
session_path = Glib::path_get_dirname (string (predetermined_path));
2063
existing_session = true;
2065
/* it doesn't exist, assume the best */
2066
session_path = Glib::path_get_dirname (string (predetermined_path));
2209
if (!ARDOUR_COMMAND_LINE::session_name.empty()) {
2211
parse_cmdline_path (ARDOUR_COMMAND_LINE::session_name, session_name, session_path, existing_session);
2213
/* don't ever reuse this */
2215
ARDOUR_COMMAND_LINE::session_name = string();
2217
if (existing_session && backend_audio_is_running) {
2219
/* just load the thing already */
2221
if (load_cmdline_session (session_name, session_path, existing_session) == 0) {
2069
session_name = basename_nosuffix (string (predetermined_path));
2226
/* make the NSD use whatever information we have */
2071
2228
new_session_dialog->set_session_name (session_name);
2072
2229
new_session_dialog->set_session_folder (session_path);
2073
new_session_dialog->set_modal (true);
2075
if (existing_session) {
2077
if (session_name.length() == 0 || session_path.length() == 0) {
2078
error << string_compose (_("Ardour cannot understand \"%1\" as a session name"), predetermined_path) << endmsg;
2082
if (Glib::file_test (predetermined_path, Glib::FILE_TEST_IS_DIR)) {
2083
Glib::ustring predicted_session_file;
2085
predicted_session_file = predetermined_path;
2086
predicted_session_file += '/';
2087
predicted_session_file += session_name;
2088
predicted_session_file += Session::statefile_suffix();
2090
if (Glib::file_test (predicted_session_file, Glib::FILE_TEST_EXISTS)) {
2091
existing_session = true;
2094
} else if (Glib::file_test (predetermined_path, Glib::FILE_TEST_EXISTS)) {
2096
if (predetermined_path.find (Session::statefile_suffix()) == predetermined_path.length() - 7) {
2097
/* existing .ardour file */
2098
existing_session = true;
2101
existing_session = false;
2104
if (existing_session && have_engine) {
2105
/* lets just try to load it */
2107
loading_dialog->set_message (_("Starting audio engine"));
2108
loading_dialog->show_all ();
2111
if (create_engine ()) {
2112
backend_audio_error (!have_engine, new_session_dialog);
2113
loading_dialog->hide ();
2117
if (load_session (session_path, session_name) == 0) {
2124
2232
/* loading failed, or we need the NSD for something */
2234
new_session_dialog->set_modal (false);
2126
2235
new_session_dialog->set_position (WIN_POS_CENTER);
2127
2236
new_session_dialog->set_current_page (0);
2128
2237
new_session_dialog->set_existing_session (existing_session);
2129
2238
new_session_dialog->reset_recent();
2132
new_session_dialog->set_have_engine (have_engine);
2241
new_session_dialog->set_have_engine (backend_audio_is_running);
2133
2242
new_session_dialog->present ();
2134
2243
response = new_session_dialog->run ();
2135
loading_dialog->hide ();
2137
2245
_session_is_new = false;
2139
2247
/* handle possible negative responses */
2141
if (response == Gtk::RESPONSE_CANCEL || response == Gtk::RESPONSE_DELETE_EVENT) {
2250
case Gtk::RESPONSE_CANCEL:
2251
case Gtk::RESPONSE_DELETE_EVENT:
2143
2252
if (!session) {
2146
2255
new_session_dialog->hide ();
2149
} else if (response == Gtk::RESPONSE_NONE) {
2258
case Gtk::RESPONSE_NONE:
2150
2259
/* "Clear" was pressed */
2152
2260
goto try_again;
2155
2263
fontconfig_dialog();
2157
/* if we're here to help set up audio parameters this is where want to do that.
2265
if (!backend_audio_is_running) {
2161
2266
if (new_session_dialog->engine_control.setup_engine ()) {
2162
2267
new_session_dialog->hide ();
2166
loading_dialog->set_message (_("Starting audio engine"));
2167
loading_dialog->show_all ();
2171
2272
if (create_engine ()) {
2172
backend_audio_error (!have_engine, new_session_dialog);
2173
loading_dialog->hide ();
2274
backend_audio_error (!backend_audio_is_running, new_session_dialog);
2174
2275
flush_pending ();
2175
/* audio setup page */
2176
2277
new_session_dialog->set_existing_session (false);
2177
2278
new_session_dialog->set_current_page (2);
2178
2280
response = Gtk::RESPONSE_NONE;
2179
2281
goto try_again;
2182
loading_dialog->hide ();
2185
/* now handle possible affirmative responses */
2187
if (response == Gtk::RESPONSE_YES) {
2189
/* YES == OPEN from the session selector */
2191
session_name = new_session_dialog->session_name();
2284
backend_audio_is_running = true;
2286
if (response == Gtk::RESPONSE_OK) {
2288
session_name = new_session_dialog->session_name();
2193
2290
if (session_name.empty()) {
2194
2291
response = Gtk::RESPONSE_NONE;
2195
2292
goto try_again;
2295
/* if the user mistakenly typed path information into the session filename entry,
2296
convert what they typed into a path & a name
2198
2299
if (session_name[0] == '/' ||
2199
2300
(session_name.length() > 2 && session_name[0] == '.' && session_name[1] == '/') ||
2200
2301
(session_name.length() > 3 && session_name[0] == '.' && session_name[1] == '.' && session_name[2] == '/')) {
2201
if (load_session (Glib::path_get_dirname (session_name), session_name)) {
2202
response = Gtk::RESPONSE_NONE;
2303
session_path = Glib::path_get_dirname (session_name);
2304
session_name = Glib::path_get_basename (session_name);
2206
2308
session_path = new_session_dialog->session_folder();
2207
if (load_session (session_path, session_name)) {
2208
response = Gtk::RESPONSE_NONE;
2213
} else if (response == Gtk::RESPONSE_OK) {
2215
/* OK == OPEN button */
2217
session_name = new_session_dialog->session_name();
2219
if (session_name.empty()) {
2220
response = Gtk::RESPONSE_NONE;
2311
template_name = Glib::ustring();
2224
2312
switch (new_session_dialog->which_page()) {
2225
2314
case NewSessionDialog::OpenPage:
2226
2315
case NewSessionDialog::EnginePage:
2228
if (session_name[0] == '/' ||
2229
(session_name.length() > 2 && session_name[0] == '.' && session_name[1] == '/') ||
2230
(session_name.length() > 3 && session_name[0] == '.' && session_name[1] == '.' && session_name[2] == '/')) {
2232
if (load_session (Glib::path_get_dirname (session_name), session_name)) {
2233
response = Gtk::RESPONSE_NONE;
2238
session_path = new_session_dialog->session_folder();
2239
if (load_session (session_path, session_name)) {
2240
response = Gtk::RESPONSE_NONE;
2246
2319
case NewSessionDialog::NewPage: /* nominally the "new" session creator, but could be in use for an old session */
2248
if (new_session_dialog->get_current_page() == 0 && ARDOUR_COMMAND_LINE::session_name.empty()) {
2249
should_be_new = true;
2252
/* handle what appear to be paths rather than just a name */
2254
if (session_name[0] == '/' ||
2255
(session_name.length() > 2 && session_name[0] == '.' && session_name[1] == '/') ||
2256
(session_name.length() > 3 && session_name[0] == '.' && session_name[1] == '.' && session_name[2] == '/')) {
2258
session_path = Glib::path_get_dirname (session_name);
2259
session_name = Glib::path_get_basename (session_name);
2263
session_path = new_session_dialog->session_folder();
2321
should_be_new = true;
2267
2323
//XXX This is needed because session constructor wants a
2268
2324
//non-existant path. hopefully this will be fixed at some point.
2270
2326
session_path = Glib::build_filename (session_path, session_name);
2272
if (!should_be_new) {
2328
if (Glib::file_test (session_path, Glib::FileTest (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
2274
if (load_session (session_path, session_name)) {
2275
response = Gtk::RESPONSE_NONE;
2330
if (ask_about_loading_existing_session (session_path)) {
2333
response = RESPONSE_NONE;
2276
2334
goto try_again;
2279
continue; /* leaves while() loop because response != NONE */
2281
} else if (Glib::file_test (session_path, Glib::FileTest (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
2283
Glib::ustring str = string_compose (_("This session\n%1\nalready exists. Do you want to open it?"), session_path);
2285
MessageDialog msg (str,
2287
Gtk::MESSAGE_WARNING,
2288
Gtk::BUTTONS_YES_NO,
2292
msg.set_name (X_("CleanupDialog"));
2293
msg.set_wmclass (X_("existing_session"), "Ardour");
2294
msg.set_position (Gtk::WIN_POS_MOUSE);
2296
switch (msg.run()) {
2298
new_session_dialog->hide ();
2299
goto_editor_window ();
2301
if (load_session (session_path, session_name)) {
2302
response = Gtk::RESPONSE_NONE;
2308
response = RESPONSE_NONE;
2309
new_session_dialog->reset ();
2310
new_session_dialog->set_existing_session (false);
2311
loading_dialog->hide ();
2316
2338
_session_is_new = true;
2318
2340
if (new_session_dialog->use_session_template()) {
2320
2342
template_name = new_session_dialog->session_template_name();
2322
new_session_dialog->hide ();
2323
goto_editor_window ();
2326
if (load_session (session_path, session_name, template_name)) {
2327
response = Gtk::RESPONSE_NONE;
2336
AutoConnectOption iconnect;
2337
AutoConnectOption oconnect;
2341
if (Profile->get_sae()) {
2345
iconnect = AutoConnectPhysical;
2346
oconnect = AutoConnectMaster;
2347
nphysin = 0; // use all available
2348
nphysout = 0; // use all available
2352
/* get settings from advanced section of NSD */
2354
if (new_session_dialog->create_control_bus()) {
2355
cchns = (uint32_t) new_session_dialog->control_channel_count();
2360
if (new_session_dialog->create_master_bus()) {
2361
mchns = (uint32_t) new_session_dialog->master_channel_count();
2366
if (new_session_dialog->connect_inputs()) {
2367
iconnect = AutoConnectPhysical;
2369
iconnect = AutoConnectOption (0);
2372
/// @todo some minor tweaks.
2374
if (new_session_dialog->connect_outs_to_master()) {
2375
oconnect = AutoConnectMaster;
2376
} else if (new_session_dialog->connect_outs_to_physical()) {
2377
oconnect = AutoConnectPhysical;
2379
oconnect = AutoConnectOption (0);
2382
nphysin = (uint32_t) new_session_dialog->input_limit_count();
2383
nphysout = (uint32_t) new_session_dialog->output_limit_count();
2386
if (build_session (session_path,
2394
engine->frame_rate() * 60 * 5)) {
2396
response = Gtk::RESPONSE_NONE;
2346
if (build_session_from_nsd (session_path, session_name)) {
2347
response = RESPONSE_NONE;
2397
2348
goto try_again;
2400
new_session_dialog->hide ();
2401
goto_editor_window ();
2412
if (response == Gtk::RESPONSE_NONE) {
2413
loading_dialog->hide ();
2414
new_session_dialog->set_existing_session (false);
2415
new_session_dialog->reset ();
2359
new_session_dialog->hide ();
2361
if (load_session (session_path, session_name, template_name)) {
2363
response = Gtk::RESPONSE_NONE;
2367
if (response == Gtk::RESPONSE_NONE) {
2368
new_session_dialog->set_existing_session (false);
2369
new_session_dialog->reset ();
2418
2373
} while (response == Gtk::RESPONSE_NONE);
2422
loading_dialog->hide ();
2423
2377
new_session_dialog->hide();
2378
new_session_dialog->reset();
2379
goto_editor_window ();
2428
2384
ARDOUR_UI::close_session ()