diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2013-09-04 22:58:56 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2013-09-04 22:58:56 -0400 |
commit | 5a3cf3363b9b782f8bd8f81b8f002b21d746d14a (patch) | |
tree | ce8590fd3e3b074e375e928fbcba1c6d0d29c879 | |
parent | 0cc4ee7b79644961967a60bd337b035e97517d4a (diff) |
save and restore the selected engine state at startup
-rw-r--r-- | gtk2_ardour/engine_dialog.cc | 49 | ||||
-rw-r--r-- | gtk2_ardour/engine_dialog.h | 3 |
2 files changed, 51 insertions, 1 deletions
diff --git a/gtk2_ardour/engine_dialog.cc b/gtk2_ardour/engine_dialog.cc index ebdf60f4d6..eddb9c3cbd 100644 --- a/gtk2_ardour/engine_dialog.cc +++ b/gtk2_ardour/engine_dialog.cc @@ -489,7 +489,8 @@ EngineControl::get_state () node->add_property ("output-latency", (*i).output_latency); node->add_property ("input-channels", (*i).input_channels); node->add_property ("output-channels", (*i).output_channels); - + node->add_property ("active", (*i).active ? "yes" : "no"); + state_nodes->add_child_nocopy (*node); } @@ -580,10 +581,32 @@ EngineControl::set_state (const XMLNode& root) continue; } state.output_channels = prop->value (); + + if ((prop = grandchild->property ("active")) == 0) { + continue; + } + state.active = string_is_affirmative (prop->value ()); states.push_back (state); } } + + /* now see if there was an active state and switch the setup to it */ + + for (StateList::const_iterator i = states.begin(); i != states.end(); ++i) { + if ((*i).active) { + sr_connection.block (); + bs_connection.block (); + backend_combo.set_active_text ((*i).backend); + driver_combo.set_active_text ((*i).driver); + device_combo.set_active_text ((*i).device); + sample_rate_combo.set_active_text ((*i).sample_rate); + buffer_size_combo.set_active_text ((*i).buffer_size); + sr_connection.unblock (); + bs_connection.unblock (); + break; + } + } } int @@ -637,6 +660,30 @@ EngineControl::setup_engine (bool start) _used = true; + /* get a pointer to the current state object, creating one if + * necessary + */ + + State* state = get_current_state (); + + if (!state) { + save_state (); + state = get_current_state (); + assert (state); + } + + /* all off */ + + for (StateList::iterator i = states.begin(); i != states.end(); ++i) { + (*i).active = false; + } + + /* mark this one active (to be used next time the dialog is + * shown) + */ + + state->active = true; + if (start) { return ARDOUR::AudioEngine::instance()->start(); } diff --git a/gtk2_ardour/engine_dialog.h b/gtk2_ardour/engine_dialog.h index a56a97caee..3ee7a388bc 100644 --- a/gtk2_ardour/engine_dialog.h +++ b/gtk2_ardour/engine_dialog.h @@ -129,6 +129,9 @@ class EngineControl : public Gtk::VBox { std::string output_latency; std::string input_channels; std::string output_channels; + bool active; + + State() : active (false) {}; }; typedef std::list<State> StateList; |