From eda27cc3de7dda78aaf24edf0ba7e75e7a9df8b9 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 6 Nov 2019 17:35:30 -0700 Subject: [PATCH] move all responsibility for autostart into StartupFSM and out of engine dialog --- gtk2_ardour/engine_dialog.cc | 12 ------------ gtk2_ardour/engine_dialog.h | 1 - gtk2_ardour/startup_fsm.cc | 32 +++++++++++++++++++++++--------- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/gtk2_ardour/engine_dialog.cc b/gtk2_ardour/engine_dialog.cc index 182a931cef..6cbe040371 100644 --- a/gtk2_ardour/engine_dialog.cc +++ b/gtk2_ardour/engine_dialog.cc @@ -470,18 +470,6 @@ EngineControl::config_parameter_changed (std::string const & p) } } -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 () { diff --git a/gtk2_ardour/engine_dialog.h b/gtk2_ardour/engine_dialog.h index 7592d4e9a8..5d3d6854d9 100644 --- a/gtk2_ardour/engine_dialog.h +++ b/gtk2_ardour/engine_dialog.h @@ -55,7 +55,6 @@ public: bool set_state (const XMLNode&); void set_desired_sample_rate (uint32_t); - bool try_autostart (); private: Gtk::Notebook notebook; diff --git a/gtk2_ardour/startup_fsm.cc b/gtk2_ardour/startup_fsm.cc index 599eb0e337..7d05ca051a 100644 --- a/gtk2_ardour/startup_fsm.cc +++ b/gtk2_ardour/startup_fsm.cc @@ -425,21 +425,35 @@ StartupFSM::start_audio_midi_setup () } if (setup_required) { - if (!session_is_new && session_existing_sample_rate > 0) { - audiomidi_dialog.set_desired_sample_rate (session_existing_sample_rate); - } + + /* Note: if autostart is enabled, and starting the engine is + * successful, but the session SR differs, there will be no + * chance to reset it. + * + * We could change this trivially with a call to + * AudioEngine::set_sample_rate(), but that opens a can of + * worms about policy, UX, GUI and more, because it isn't clear + * whether that's the correct thing to do. So for now (Nov + * 2019) we simply try the autostart if the user asked for it, + * and if necessary a session SR mismatch dialog will appear + * during loading. + */ if (!session_is_new && (Config->get_try_autostart_engine () || g_getenv ("ARDOUR_TRY_AUTOSTART_ENGINE"))) { - audiomidi_dialog.try_autostart (); - - if (ARDOUR::AudioEngine::instance()->running()) { - DEBUG_TRACE (DEBUG::GuiStartup, "autostart successful, audio/MIDI setup dialog not required\n"); - engine_running (); - return; + if (!AudioEngine::instance()->start ()) { + if (ARDOUR::AudioEngine::instance()->running()) { + DEBUG_TRACE (DEBUG::GuiStartup, "autostart successful, audio/MIDI setup dialog not required\n"); + engine_running (); + return; + } } } + if (!session_is_new && session_existing_sample_rate > 0) { + audiomidi_dialog.set_desired_sample_rate (session_existing_sample_rate); + } + show_audiomidi_dialog (); DEBUG_TRACE (DEBUG::GuiStartup, "audiomidi shown and waiting\n");