diff options
author | Tim Mayberry <mojofunk@gmail.com> | 2015-07-29 15:46:26 +1000 |
---|---|---|
committer | Tim Mayberry <mojofunk@gmail.com> | 2015-07-31 09:59:53 +1000 |
commit | 2437bbbe2315a4f9991874ea8baa5d91230bc139 (patch) | |
tree | 5a922187630892e640978ecd1d730f14d83a87f1 /gtk2_ardour/engine_dialog.cc | |
parent | b2817bfac5499e77066817f83cccd0e206b6d20f (diff) |
Fix state restoration in Engine dialog for Backends with driver selection
Connect to the backend_combo changed signal after setting state as calling
backend_combo.set_active_text() in set_state was triggering backend_changed(),
which would then see the driver_combo had not been set and set it to the
incorrect value.
The value/name of the backend needs to be restored first then we can populate
the driver combo and set the correct active entry from the saved state. After
which backend_changed() will populate the device combo's etc so they can then
be set to the correct active values from the saved state.
Diffstat (limited to 'gtk2_ardour/engine_dialog.cc')
-rw-r--r-- | gtk2_ardour/engine_dialog.cc | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/gtk2_ardour/engine_dialog.cc b/gtk2_ardour/engine_dialog.cc index 3e9b123485..866f6e563f 100644 --- a/gtk2_ardour/engine_dialog.cc +++ b/gtk2_ardour/engine_dialog.cc @@ -119,7 +119,6 @@ EngineControl::EngineControl () } set_popdown_strings (backend_combo, backend_names); - backend_combo.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::backend_changed)); /* setup basic packing characteristics for the table used on the main * tab of the notebook @@ -303,6 +302,7 @@ EngineControl::EngineControl () /* Connect to signals */ + backend_combo.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::backend_changed)); driver_combo.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::driver_changed)); sample_rate_combo.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::sample_rate_changed)); buffer_size_combo.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::buffer_size_changed)); @@ -851,6 +851,23 @@ EngineControl::print_channel_count (Gtk::SpinButton* sb) return true; } +bool +EngineControl::set_driver_popdown_strings () +{ + string backend_name = backend_combo.get_active_text(); + boost::shared_ptr<ARDOUR::AudioBackend> backend; + + if (!(backend = ARDOUR::AudioEngine::instance()->set_backend (backend_name, "ardour", ""))) { + /* eh? setting the backend failed... how ? */ + /* A: stale config contains a backend that does not exist in current build */ + return false; + } + + vector<string> drivers = backend->enumerate_drivers(); + set_popdown_strings (driver_combo, drivers); + return true; +} + // @return true if there are devices available bool EngineControl::set_device_popdown_strings () @@ -1750,11 +1767,19 @@ EngineControl::set_state (const XMLNode& root) if ((*i)->active) { PBD::Unwinder<uint32_t> protect_ignore_changes (ignore_changes, ignore_changes + 1); backend_combo.set_active_text ((*i)->backend); + + /* The driver popdown strings need to be populated now so that + * set_active_text will actually set a valid entry. Then + * backend_changed() will populate all the other combo's so they + * can also be set to valid entries and the state will be restored + * correctly. + */ + set_driver_popdown_strings (); driver_combo.set_active_text ((*i)->driver); + backend_changed (); + device_combo.set_active_text ((*i)->device); - fprintf (stderr, "setting input device to: %s ", (*i)->input_device.c_str()); input_device_combo.set_active_text ((*i)->input_device); - fprintf (stderr, "setting output device to: %s ", (*i)->output_device.c_str()); output_device_combo.set_active_text ((*i)->output_device); sample_rate_combo.set_active_text (rate_as_string ((*i)->sample_rate)); set_active_text_if_present (buffer_size_combo, bufsize_as_string ((*i)->buffer_size)); |