From 1c4d00e8b70785ce58f868645dad93afa1855193 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 3 Aug 2013 11:57:56 -0400 Subject: audioengine branch can now load and run at least one test session. currently hard-coded to deal only with the situation where JACK is already running --- gtk2_ardour/ardour_ui.cc | 36 ++++++++++++++++++------------------ gtk2_ardour/ardour_ui.h | 2 +- gtk2_ardour/engine_dialog.cc | 32 +++++++------------------------- 3 files changed, 26 insertions(+), 44 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 12f3feafa1..e764c50d4e 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -61,6 +61,7 @@ #include "midi++/manager.h" #include "ardour/ardour.h" +#include "ardour/audio_backend.h" #include "ardour/audioengine.h" #include "ardour/audiofilesource.h" #include "ardour/automation_watch.h" @@ -373,6 +374,8 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir) _process_thread->init (); DPIReset.connect (sigc::mem_fun (*this, &ARDOUR_UI::resize_text_widgets)); + + attach_to_engine (); } GlobalPortMatrixWindow* @@ -384,18 +387,10 @@ ARDOUR_UI::create_global_port_matrix (ARDOUR::DataType type) return new GlobalPortMatrixWindow (_session, type); } -int -ARDOUR_UI::create_engine () +void +ARDOUR_UI::attach_to_engine () { - // this gets called every time by new_session() - - if (engine) { - return 0; - } - - loading_message (_("Starting audio engine")); - - AudioEngine* engine = AudioEngine::instance(); + engine = AudioEngine::instance(); engine->Stopped.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::engine_stopped, this), gui_context()); engine->Running.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::engine_running, this), gui_context()); @@ -405,8 +400,6 @@ ARDOUR_UI::create_engine () engine->BackendAvailable.connect_same_thread (forever_connections, boost::bind (&ARDOUR_UI::post_engine, this)); ARDOUR::Port::set_connecting_blocked (ARDOUR_COMMAND_LINE::no_connect_ports); - - return 0; } void @@ -414,7 +407,7 @@ ARDOUR_UI::post_engine () { cerr << "Backend available!\n"; - /* Things to be done once we create the AudioEngine + /* Things to be done once we have a backend running in the AudioEngine */ ARDOUR::init_post_engine (); @@ -2572,6 +2565,17 @@ ARDOUR_UI::get_session_parameters (bool quit_on_cancel, bool should_be_new, stri int ret = -1; bool likely_new = false; + /* if the audio/midi backend does not require setup, get our use of it underway + * right here + */ + + if (!EngineControl::need_setup()) { + vector backends = AudioEngine::instance()->available_backends(); + cerr << "Setting up backend " << backends.front()->name; + AudioEngine::instance()->set_backend (backends.front()->name, ARDOUR_COMMAND_LINE::backend_client_name, ARDOUR_COMMAND_LINE::backend_session_uuid); + AudioEngine::instance()->start (); + } + /* deal with any existing DIRTY session now, rather than later. don't * treat a non-dirty session this way, so that it stays visible * as we bring up the new session dialog. @@ -2693,10 +2697,6 @@ ARDOUR_UI::get_session_parameters (bool quit_on_cancel, bool should_be_new, stri } } - if (create_engine ()) { - break; - } - if (Glib::file_test (session_path, Glib::FileTest (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) { if (likely_new && !nsm) { diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index 5817293b29..c4ac0e67d7 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -263,7 +263,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr session_add_midi_route (false); }*/ - int create_engine (); + void attach_to_engine (); void post_engine (); gint exit_on_main_window_close (GdkEventAny *); diff --git a/gtk2_ardour/engine_dialog.cc b/gtk2_ardour/engine_dialog.cc index a9e04d8db0..2db93d75ec 100644 --- a/gtk2_ardour/engine_dialog.cc +++ b/gtk2_ardour/engine_dialog.cc @@ -44,6 +44,8 @@ #include #include +#include "ardour/audio_backend.h" +#include "ardour/audioengine.h" #include "ardour/rc_configuration.h" #include "pbd/convert.h" @@ -594,33 +596,13 @@ EngineControl::build_command_line (vector& cmd) bool EngineControl::need_setup () { - return !engine_running(); -} - -bool -EngineControl::engine_running () -{ - EnvironmentalProtectionAgency* global_epa = EnvironmentalProtectionAgency::get_global_epa (); - boost::scoped_ptr current_epa; - - /* revert all environment settings back to whatever they were when - * ardour started, because ardour's startup script may have reset - * something in ways that interfere with finding/starting JACK. - */ + vector backends = ARDOUR::AudioEngine::instance()->available_backends(); - if (global_epa) { - current_epa.reset (new EnvironmentalProtectionAgency(true)); /* will restore settings when we leave scope */ - global_epa->restore (); - } - - jack_status_t status; - jack_client_t* c = jack_client_open ("ardourprobe", JackNoStartServer, &status); - - if (status == 0) { - jack_client_close (c); - return true; + if (backends.size() == 1 && backends.front()->already_configured()) { + return false; } - return false; + + return true; } int -- cgit v1.2.3