diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 237d7708e9..13b1308641 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -951,7 +951,7 @@ class Session : public PBD::StatefulDestructible void update_latency_compensation (bool, bool); private: - int create (bool& new_session, string* mix_template, nframes_t initial_length); + int create (); void destroy (); void initialize_start_and_end_locations(nframes_t start, nframes_t end); diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 59c326264f..bf777a73d9 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -126,8 +126,6 @@ Session::Session (AudioEngine &eng, _click_io ((IO*) 0), main_outs (0) { - bool new_session; - if (!eng.connected()) { throw failed_constructor(); } @@ -138,16 +136,25 @@ Session::Session (AudioEngine &eng, n_physical_inputs = _engine.n_physical_inputs(); first_stage_init (fullpath, snapshot_name); + + initialize_start_and_end_locations(0, compute_initial_length ()); - new_session = !g_file_test (_path.c_str(), GFileTest (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)); + bool new_session = !g_file_test (_path.c_str(), GFileTest (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)); + if (new_session) { - if (create (new_session, mix_template, compute_initial_length())) { - cerr << "create failed\n"; + // A mix_template must be specified if using this constructor + // to create a new session. + assert(mix_template); + + if (create () || + !create_session_file_from_template (*mix_template)) { destroy (); throw failed_constructor (); } + // Continue construction like a normal saved session from now on. + new_session = false; } - + if (second_stage_init (new_session)) { destroy (); throw failed_constructor (); @@ -192,8 +199,6 @@ Session::Session (AudioEngine &eng, main_outs (0) { - bool new_session; - if (!eng.connected()) { throw failed_constructor(); } @@ -213,13 +218,13 @@ Session::Session (AudioEngine &eng, first_stage_init (fullpath, snapshot_name); - new_session = !g_file_test (_path.c_str(), GFileTest (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)); + initialize_start_and_end_locations(0, initial_length); - if (new_session) { - if (create (new_session, 0, initial_length)) { + if (g_file_test (_path.c_str(), GFileTest (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) || + create () || + !create_session_file ()) { destroy (); throw failed_constructor (); - } } { @@ -254,7 +259,7 @@ Session::Session (AudioEngine &eng, Config->set_input_auto_connect (input_ac); Config->set_output_auto_connect (output_ac); - if (second_stage_init (new_session)) { + if (second_stage_init (true)) { destroy (); throw failed_constructor (); } diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 4c3e4d2dc0..c41d7d742c 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -499,7 +499,7 @@ Session::create_session_file_from_template (const string& template_path) } int -Session::create (bool& new_session, string* mix_template, nframes_t initial_length) +Session::create () { string dir; @@ -541,19 +541,6 @@ Session::create (bool& new_session, string* mix_template, nframes_t initial_leng return -1; } - - /* check new_session so we don't overwrite an existing one */ - - if (mix_template) { - if(!create_session_file_from_template(*mix_template)) return -1; - new_session = false; - return 0; - } - - initialize_start_and_end_locations(0, initial_length); - - if (!create_session_file()) return -1; - return 0; }