diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2019-12-11 14:52:46 -0700 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2019-12-11 14:53:00 -0700 |
commit | ff7fe6d4d6c0d966327f553118255444f5b589e3 (patch) | |
tree | c4b450f896db5485badea85381ca82f16fe8c802 | |
parent | debcb226976688bd43f85019c1088964fcc42971 (diff) |
when loading a session into a running instance, if the SR doesn't match the engine, stop engine and show dialog
-rw-r--r-- | gtk2_ardour/ardour_ui.h | 2 | ||||
-rw-r--r-- | gtk2_ardour/ardour_ui_session.cc | 59 |
2 files changed, 54 insertions, 7 deletions
diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index da62ce2062..867ef7b27a 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -212,6 +212,8 @@ public: void finish(); int load_session (const std::string& path, const std::string& snapshot, std::string mix_template = std::string()); + int load_session_stage_two (const std::string& path, const std::string& snapshot, std::string mix_template = std::string()); + void audio_midi_setup_reconfigure_done (int response, std::string path, std::string snapshot, std::string mix_template); bool session_load_in_progress; int build_session (const std::string& path, const std::string& snapshot, ARDOUR::BusProfile const *); bool session_is_new() const { return _session_is_new; } diff --git a/gtk2_ardour/ardour_ui_session.cc b/gtk2_ardour/ardour_ui_session.cc index 8550b5e235..4cb73619e5 100644 --- a/gtk2_ardour/ardour_ui_session.cc +++ b/gtk2_ardour/ardour_ui_session.cc @@ -337,21 +337,66 @@ ARDOUR_UI::load_session (const std::string& path, const std::string& snap_name, } PBD::Unwinder<bool> lsu (session_load_in_progress, true); - Session *new_session; int unload_status; - int retval = -1; + bool had_session = false; if (_session) { + had_session = true; + unload_status = unload_session (); - if (unload_status < 0) { - goto out; - } else if (unload_status > 0) { - retval = 0; - goto out; + if (unload_status != 0) { + hide_splash (); + return -1; + } + } + + if (had_session) { + float sr; + SampleFormat sf; + string pv; + + Session::get_info_from_path (Glib::build_filename (path, snap_name + statefile_suffix), sr, sf, pv); + + /* this will stop the engine if the SR is different */ + + audio_midi_setup->set_desired_sample_rate (sr); + + if (!AudioEngine::instance()->running()) { + audio_midi_setup->set_position (WIN_POS_CENTER); + audio_midi_setup->present (); + audio_midi_setup->signal_response().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::audio_midi_setup_reconfigure_done), path, snap_name, mix_template)); + /* not done yet, but we're avoiding modal dialogs */ + return 0; + } + } + + return load_session_stage_two (path, snap_name, mix_template); +} + +void +ARDOUR_UI::audio_midi_setup_reconfigure_done (int response, std::string path, std::string snap_name, std::string mix_template) +{ + switch (response) { + case Gtk::RESPONSE_DELETE_EVENT: + break; + default: + if (!AudioEngine::instance()->running()) { + return; // keep dialog visible, maybe try again } } + audio_midi_setup->hide(); + + (void) load_session_stage_two (path, snap_name, mix_template); +} + +int +ARDOUR_UI::load_session_stage_two (const std::string& path, const std::string& snap_name, std::string mix_template) +{ + Session *new_session; + int retval = -1; + BootMessage (string_compose (_("Please wait while %1 loads your session"), PROGRAM_NAME)); try { |