summaryrefslogtreecommitdiff
path: root/libs/ardour
diff options
context:
space:
mode:
authorTim Mayberry <mojofunk@gmail.com>2007-05-18 02:45:49 +0000
committerTim Mayberry <mojofunk@gmail.com>2007-05-18 02:45:49 +0000
commit944601ec2d8b1be6764922153fa8ac88babcbee1 (patch)
tree07a7b8d29165c06504f5a000093f1e7b0699035a /libs/ardour
parent0b0c764f4c11a9e350eb5f512bd203ca461d0e5b (diff)
Move code from Session::create into the Session constructors
git-svn-id: svn://localhost/ardour2/trunk@1871 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour')
-rw-r--r--libs/ardour/ardour/session.h2
-rw-r--r--libs/ardour/session.cc31
-rw-r--r--libs/ardour/session_state.cc15
3 files changed, 20 insertions, 28 deletions
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;
}