13
0

Move code from Session::create into the Session constructors

git-svn-id: svn://localhost/ardour2/trunk@1871 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Tim Mayberry 2007-05-18 02:45:49 +00:00
parent 0b0c764f4c
commit 944601ec2d
3 changed files with 20 additions and 28 deletions

View File

@ -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);

View File

@ -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 ();
}

View File

@ -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;
}