add a try-autostart-engine option (most recently used settings)
authorRobin Gareus <robin@gareus.org>
Mon, 18 Apr 2016 12:11:22 +0000 (14:11 +0200)
committerRobin Gareus <robin@gareus.org>
Mon, 18 Apr 2016 12:11:22 +0000 (14:11 +0200)
gtk2_ardour/ardour_ui.cc
gtk2_ardour/engine_dialog.cc
gtk2_ardour/engine_dialog.h

index 39bdc9280a9547fb0a75e16675eee6ade68a2986..c368572e9c6fc25849b5ef278f5a83abaf7cfd4f 100644 (file)
@@ -5122,10 +5122,19 @@ ARDOUR_UI::do_audio_midi_setup (uint32_t desired_sample_rate)
        audio_midi_setup->set_desired_sample_rate (desired_sample_rate);
        audio_midi_setup->set_position (WIN_POS_CENTER);
 
-       int response;
+       // TODO make this a preference.
+       // (engine state is parsed by the GUI, but currently saved
+       // in preferences: ARDOUR::Config->extra_xml
+       // soooo where should this option go?)
+       if (getenv("TRY_AUTOSTART_ENGINE")) {
+               audio_midi_setup->try_autostart ();
+               if (ARDOUR::AudioEngine::instance()->running()) {
+                       return 0;
+               }
+       }
 
        while (true) {
-               response = audio_midi_setup->run();
+               int response = audio_midi_setup->run();
                switch (response) {
                case Gtk::RESPONSE_OK:
                        if (!AudioEngine::instance()->running()) {
index da0e6168d93eff63e7ad914506dbc35e09abd5e7..be211702649a0f3fd2b3ea101f6bbb52c15010f2 100644 (file)
@@ -423,6 +423,18 @@ EngineControl::on_show ()
        ok_button->grab_focus();
 }
 
+bool
+EngineControl::try_autostart ()
+{
+       if (!start_stop_button.get_sensitive()) {
+               return false;
+       }
+       if (ARDOUR::AudioEngine::instance()->running()) {
+               return true;
+       }
+       return start_engine ();
+}
+
 bool
 EngineControl::start_engine ()
 {
index faf12d7c98bfa98e7af7f06d7ed3e6ca47bf632a..8f47f2b5a35d3668cc7c5f4adf0f7754999e13bf 100644 (file)
@@ -49,6 +49,7 @@ class EngineControl : public ArdourDialog, public PBD::ScopedConnectionList {
     bool set_state (const XMLNode&);
 
     void set_desired_sample_rate (uint32_t);
+    bool try_autostart ();
 
   private:
     Gtk::Notebook notebook;