diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2013-09-12 17:06:21 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2013-09-12 17:25:01 -0400 |
commit | 28d692b4900d8c428c2cd3b9008c897ec8943724 (patch) | |
tree | f4505cabcf412c17285ef2d062b73cf733c8c384 /libs/ardour/session.cc | |
parent | 8432f78346800a8e897d79deb61396b67cbd9c18 (diff) |
don't stop metering thread when session is removed; move engine-setup code into its own method. sorry, ardour build-from-source folk :)
Diffstat (limited to 'libs/ardour/session.cc')
-rw-r--r-- | libs/ardour/session.cc | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 94882c13b3..cad869a577 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -286,39 +286,9 @@ Session::Session (AudioEngine &eng, } } - /* we need the audioengine to be up and usable to make much more - * progress with construction, so lets get that started if it isn't already. - */ - - if (_engine.current_backend() == 0) { - /* backend is unknown ... */ - boost::optional<int> r = AudioEngineSetupRequired (sr); - if (r.get_value_or (-1) != 0) { - destroy (); - throw failed_constructor(); - } - } else if (_engine.setup_required()) { - /* backend is known, but setup is needed */ - boost::optional<int> r = AudioEngineSetupRequired (sr); - if (r.get_value_or (-1) != 0) { - destroy (); - throw failed_constructor(); - } - } else if (!_engine.running()) { - if (_engine.start()) { - destroy (); - throw failed_constructor (); - } - } - - /* at this point the engine should be connected (i.e. interacting - with a backend device (or psuedo-device) and available to us - for determinining sample rates and other settings. - */ - - if (!_engine.connected()) { + if (ensure_engine (sr)) { destroy (); - throw failed_constructor(); + throw failed_constructor (); } if (post_engine_init ()) { @@ -363,6 +333,37 @@ Session::~Session () destroy (); } +int +Session::ensure_engine (uint32_t desired_sample_rate) +{ + 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 (_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 0; +} + void Session::destroy () { |