From b194c1ad88b0b6a0b1c324a34980010a5bd0cb28 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 10 Oct 2013 16:18:27 -0400 Subject: [PATCH] more fixes and rationalizations for MIDI option handling in the audio MIDI setup --- gtk2_ardour/engine_dialog.cc | 35 +++++++++++++++++++++++++++++++---- gtk2_ardour/engine_dialog.h | 2 ++ 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/gtk2_ardour/engine_dialog.cc b/gtk2_ardour/engine_dialog.cc index 8ec62f844c..3e7fc76c01 100644 --- a/gtk2_ardour/engine_dialog.cc +++ b/gtk2_ardour/engine_dialog.cc @@ -58,6 +58,9 @@ using namespace Gtkmm2ext; using namespace PBD; using namespace Glib; +static const unsigned int midi_tab = -1; /* not currently in use */ +static const unsigned int latency_tab = 1; /* zero-based, page zero is the main setup page */ + EngineControl::EngineControl () : ArdourDialog (_("Audio/MIDI Setup")) , basic_packer (9, 3) @@ -254,6 +257,7 @@ EngineControl::EngineControl () 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)); device_combo.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::device_changed)); + midi_option_combo.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::midi_option_changed)); input_latency.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::parameter_changed)); output_latency.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::parameter_changed)); @@ -887,6 +891,14 @@ EngineControl::show_buffer_duration () buffer_size_duration_label.set_text (buf); } +void +EngineControl::midi_option_changed () +{ + if (!ignore_changes) { + save_state (); + } +} + void EngineControl::parameter_changed () { @@ -963,6 +975,7 @@ EngineControl::store_state (State& state) state.output_latency = get_output_latency (); state.input_channels = get_input_channels (); state.output_channels = get_output_channels (); + state.midi_option = get_midi_option (); } void @@ -1195,6 +1208,10 @@ EngineControl::push_state_to_backend (bool start) if (get_buffer_size() != backend->buffer_size()) { change_bufsize = true; } + + if (get_midi_option() != backend->midi_option()) { + change_midi = true; + } /* zero-requested channels means "all available" */ @@ -1228,6 +1245,7 @@ EngineControl::push_state_to_backend (bool start) change_bufsize = true; change_channels = true; change_latency = true; + change_midi = true; } } else { @@ -1278,6 +1296,7 @@ EngineControl::push_state_to_backend (bool start) if (change_driver || change_device || change_channels || change_latency || (change_rate && !backend->can_change_sample_rate_when_running()) || + change_midi || (change_bufsize && !backend->can_change_buffer_size_when_running())) { restart_required = true; } else { @@ -1286,7 +1305,7 @@ EngineControl::push_state_to_backend (bool start) if (was_running) { - if (!change_driver && !change_device && !change_channels && !change_latency) { + if (!change_driver && !change_device && !change_channels && !change_latency && !change_midi) { /* no changes in any parameters that absolutely require a * restart, so check those that might be changeable without a * restart @@ -1351,7 +1370,9 @@ EngineControl::push_state_to_backend (bool start) } } - backend->set_midi_option (midi_option_combo.get_active_text()); + if (change_midi) { + backend->set_midi_option (get_midi_option()); + } if (start || (was_running && restart_required)) { if (ARDOUR_UI::instance()->reconnect_to_engine()) { @@ -1427,6 +1448,12 @@ EngineControl::get_buffer_size () const return samples; } +string +EngineControl::get_midi_option () const +{ + return midi_option_combo.get_active_text(); +} + uint32_t EngineControl::get_input_channels() const { @@ -1519,12 +1546,12 @@ EngineControl::on_switch_page (GtkNotebookPage*, guint page_num) apply_button->set_sensitive (false); } - if (page_num == 1) { + if (page_num == midi_tab) { /* MIDI tab */ refresh_midi_display (); } - if (page_num == 2) { + if (page_num == latency_tab) { /* latency tab */ if (!ARDOUR::AudioEngine::instance()->running()) { diff --git a/gtk2_ardour/engine_dialog.h b/gtk2_ardour/engine_dialog.h index ae9c360e55..5ecd840e98 100644 --- a/gtk2_ardour/engine_dialog.h +++ b/gtk2_ardour/engine_dialog.h @@ -118,6 +118,7 @@ class EngineControl : public ArdourDialog, public PBD::ScopedConnectionList { void sample_rate_changed (); void buffer_size_changed (); void parameter_changed (); + void midi_option_changed (); void setup_midi_tab_for_backend (); void setup_midi_tab_for_jack (); @@ -134,6 +135,7 @@ class EngineControl : public ArdourDialog, public PBD::ScopedConnectionList { std::string get_device_name() const; std::string get_driver() const; std::string get_backend() const; + std::string get_midi_option () const; void device_changed (); void list_devices ();