summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2019-10-11 10:25:08 -0600
committerPaul Davis <paul@linuxaudiosystems.com>2019-10-11 10:25:32 -0600
commit789f08891b3c05996545a5e2fdaecb52fdf332a4 (patch)
tree4bf5021367a1dd6e36cb69b182ff719cb1e705f3 /libs
parent1c672e51912aa34f2b283ef9d8cd265aaf5f5a97 (diff)
remove responsibility for starting AudioEngine from Session
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/session.cc72
1 files changed, 9 insertions, 63 deletions
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index 469cf0b9b3..3e725881e3 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -322,8 +322,6 @@ Session::Session (AudioEngine &eng,
, _selection (new CoreSelection (*this))
, _global_locate_pending (false)
{
- uint32_t sr = 0;
-
created_with = string_compose ("%1 %2", PROGRAM_NAME, revision);
pthread_mutex_init (&_rt_emit_mutex, 0);
@@ -339,20 +337,13 @@ Session::Session (AudioEngine &eng,
setup_lua ();
+ assert (AudioEngine::instance()->running());
+ immediately_post_engine ();
+
if (_is_new) {
Stateful::loading_state_version = CURRENT_SESSION_FILE_VERSION;
- if (ensure_engine (sr, true)) {
- destroy ();
- throw SessionException (_("Cannot connect to audio/midi engine"));
- }
-
- // set samplerate for plugins added early
- // e.g from templates or MB channelstrip
- set_block_size (_engine.samples_per_cycle());
- set_sample_rate (_engine.sample_rate());
-
if (create (mix_template, bus_profile)) {
destroy ();
throw SessionException (_("Session initialization failed"));
@@ -388,27 +379,10 @@ Session::Session (AudioEngine &eng,
if (load_state (_current_snapshot_name)) {
throw SessionException (_("Failed to load state"));
}
-
- /* try to get sample rate from XML state so that we
- * can influence the SR if we set up the audio
- * engine.
- */
-
- if (state_tree) {
- XMLProperty const * prop;
- XMLNode const * root (state_tree->root());
- if ((prop = root->property (X_("sample-rate"))) != 0) {
- sr = atoi (prop->value());
- }
- }
-
- if (ensure_engine (sr, false)) {
- destroy ();
- throw SessionException (_("Cannot connect to audio/midi engine"));
- }
}
int err = post_engine_init ();
+
if (err) {
destroy ();
switch (err) {
@@ -504,39 +478,6 @@ Session::init_name_id_counter (guint n)
}
int
-Session::ensure_engine (uint32_t desired_sample_rate, bool isnew)
-{
- if (_engine.current_backend() == 0) {
- /* backend is unknown ... */
- boost::optional<int> r = AudioEngineSetupRequired (desired_sample_rate);
- if (r.get_value_or (-1) != 0) {
- return -1;
- }
- } else if (!isnew && _engine.running() && _engine.sample_rate () == desired_sample_rate) {
- /* keep engine */
- } else if (_engine.setup_required()) {
- /* backend is known, but setup is needed */
- boost::optional<int> r = AudioEngineSetupRequired (desired_sample_rate);
- if (r.get_value_or (-1) != 0) {
- return -1;
- }
- } else if (!_engine.running()) {
- if (_engine.start()) {
- return -1;
- }
- }
-
- /* at this point the engine should be running */
-
- if (!_engine.running()) {
- return -1;
- }
-
- return immediately_post_engine ();
-
-}
-
-int
Session::immediately_post_engine ()
{
/* Do various initializations that should take place directly after we
@@ -586,6 +527,11 @@ Session::immediately_post_engine ()
* can we do that? */
_engine.PortRegisteredOrUnregistered.connect_same_thread (*this, boost::bind (&Session::setup_bundles, this));
+ // set samplerate for plugins added early
+ // e.g from templates or MB channelstrip
+ set_block_size (_engine.samples_per_cycle());
+ set_sample_rate (_engine.sample_rate());
+
return 0;
}