X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fengine_dialog.cc;h=f3dba387abbb5109e035decff1738eaf17bc5841;hb=5f9e81b105e84988a92c1f448fa46d9054893b55;hp=58423892449455f31bf28a29f27c41aa5df21de7;hpb=61ab4f0fb0556e4fc9ba1660dafc3579abb87c26;p=ardour.git diff --git a/gtk2_ardour/engine_dialog.cc b/gtk2_ardour/engine_dialog.cc index 5842389244..f3dba387ab 100644 --- a/gtk2_ardour/engine_dialog.cc +++ b/gtk2_ardour/engine_dialog.cc @@ -58,11 +58,12 @@ using namespace Gtk; using namespace Gtkmm2ext; using namespace PBD; using namespace Glib; +using namespace ARDOUR_UI_UTILS; static const unsigned int midi_tab = 2; static const unsigned int latency_tab = 1; /* zero-based, page zero is the main setup page */ -static const char* results_markup = X_("%1"); +static const char* results_markup = X_("%1"); EngineControl::EngineControl () : ArdourDialog (_("Audio/MIDI Setup")) @@ -141,16 +142,14 @@ EngineControl::EngineControl () lm_table.attach (lm_title, 0, 3, row, row+1, xopt, (AttachOptions) 0); row++; - Gtk::Label* preamble; - - preamble = manage (new Label); - preamble->set_width_chars (60); - preamble->set_line_wrap (true); - preamble->set_markup (_("Turn down the volume on your audio equipment to a very low level.")); + lm_preamble.set_width_chars (60); + lm_preamble.set_line_wrap (true); + lm_preamble.set_markup (_("Turn down the volume on your audio equipment to a very low level.")); - lm_table.attach (*preamble, 0, 3, row, row+1, AttachOptions(FILL|EXPAND), (AttachOptions) 0); + lm_table.attach (lm_preamble, 0, 3, row, row+1, AttachOptions(FILL|EXPAND), (AttachOptions) 0); row++; + Gtk::Label* preamble; preamble = manage (new Label); preamble->set_width_chars (60); preamble->set_line_wrap (true); @@ -275,11 +274,15 @@ EngineControl::EngineControl () ARDOUR::AudioEngine::instance()->Stopped.connect (stopped_connection, MISSING_INVALIDATOR, boost::bind (&EngineControl::engine_stopped, this), gui_context()); ARDOUR::AudioEngine::instance()->Halted.connect (stopped_connection, MISSING_INVALIDATOR, boost::bind (&EngineControl::engine_stopped, this), gui_context()); + if (audio_setup) { + set_state (*audio_setup); + } + { + /* ignore: don't save state */ PBD::Unwinder protect_ignore_changes (ignore_changes, ignore_changes + 1); backend_changed (); } - maybe_display_saved_state(); /* Connect to signals */ @@ -294,13 +297,16 @@ EngineControl::EngineControl () input_channels.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::parameter_changed)); output_channels.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::parameter_changed)); - if (audio_setup) { - set_state (*audio_setup); - } - notebook.signal_switch_page().connect (sigc::mem_fun (*this, &EngineControl::on_switch_page)); } +void +EngineControl::on_show () +{ + ArdourDialog::on_show (); + ok_button->grab_focus(); +} + void EngineControl::on_response (int response_id) { @@ -367,7 +373,10 @@ EngineControl::build_notebook () basic_vbox.pack_start (*hpacker); } - basic_vbox.show_all (); + { + PBD::Unwinder protect_ignore_changes (ignore_changes, ignore_changes + 1); + basic_vbox.show_all (); + } } void @@ -533,29 +542,35 @@ EngineControl::enable_latency_tab () ARDOUR::AudioEngine::instance()->get_physical_outputs (type, outputs); ARDOUR::AudioEngine::instance()->get_physical_inputs (type, inputs); - if (inputs.empty() || outputs.empty()) { + if (!ARDOUR::AudioEngine::instance()->running()) { + MessageDialog msg (_("Failed to start or connect to audio-engine.\n\nLatency calibration requires a working audio interface.")); + notebook.set_current_page (0); + msg.run (); + return; + } + else if (inputs.empty() || outputs.empty()) { MessageDialog msg (_("Your selected audio configuration is playback- or capture-only.\n\nLatency calibration requires playback and capture")); - lm_measure_button.set_sensitive (false); notebook.set_current_page (0); msg.run (); return; } - if (!outputs.empty()) { - set_popdown_strings (lm_output_channel_combo, outputs); - lm_output_channel_combo.set_active_text (outputs.front()); - lm_output_channel_combo.set_sensitive (true); + lm_back_button_signal.disconnect(); + if (_measure_midi) { + lm_back_button_signal = lm_back_button.signal_clicked().connect (sigc::bind (sigc::mem_fun (notebook, &Gtk::Notebook::set_current_page), midi_tab)); + lm_preamble.hide (); } else { - lm_output_channel_combo.set_sensitive (false); + lm_back_button_signal = lm_back_button.signal_clicked().connect (sigc::bind (sigc::mem_fun (notebook, &Gtk::Notebook::set_current_page), 0)); + lm_preamble.show (); } - if (!inputs.empty()) { - set_popdown_strings (lm_input_channel_combo, inputs); - lm_input_channel_combo.set_active_text (inputs.front()); - lm_input_channel_combo.set_sensitive (true); - } else { - lm_input_channel_combo.set_sensitive (false); - } + set_popdown_strings (lm_output_channel_combo, outputs); + lm_output_channel_combo.set_active_text (outputs.front()); + lm_output_channel_combo.set_sensitive (true); + + set_popdown_strings (lm_input_channel_combo, inputs); + lm_input_channel_combo.set_active_text (inputs.front()); + lm_input_channel_combo.set_sensitive (true); lm_measure_button.set_sensitive (true); } @@ -701,9 +716,20 @@ EngineControl::backend_changed () if (!drivers.empty()) { { + string current_driver; + current_driver = backend->driver_name (); + + // driver might not have been set yet + if (current_driver == "") { + current_driver = driver_combo.get_active_text (); + if (current_driver == "") + // driver has never been set, make sure it's not blank + current_driver = drivers.front (); + } + PBD::Unwinder protect_ignore_changes (ignore_changes, ignore_changes + 1); set_popdown_strings (driver_combo, drivers); - driver_combo.set_active_text (drivers.front()); + driver_combo.set_active_text (current_driver); } driver_changed (); @@ -785,13 +811,29 @@ EngineControl::list_devices () update_sensitivity (); { + string current_device; + current_device = backend->device_name (); + if (current_device == "") { + // device might not have been set yet + current_device = device_combo.get_active_text (); + if (current_device == "") + // device has never been set, make sure it's not blank + current_device = available_devices.front (); + } + PBD::Unwinder protect_ignore_changes (ignore_changes, ignore_changes + 1); set_popdown_strings (device_combo, available_devices); - device_combo.set_active_text (available_devices.front()); + + device_combo.set_active_text (current_device); } device_changed (); + input_latency.set_sensitive (true); + output_latency.set_sensitive (true); + input_channels.set_sensitive (true); + output_channels.set_sensitive (true); + ok_button->set_sensitive (true); apply_button->set_sensitive (true); @@ -1049,8 +1091,8 @@ EngineControl::get_matching_state ( { for (StateList::iterator i = states.begin(); i != states.end(); ++i) { if ((*i)->backend == backend && - (*i)->driver == driver && - (*i)->device == device) { + (!_have_control || ((*i)->driver == driver && (*i)->device == device))) + { return (*i); } } @@ -1077,11 +1119,19 @@ EngineControl::get_saved_state_for_currently_displayed_backend_and_device () EngineControl::State EngineControl::save_state () { + State state; + if (!_have_control) { - return State(); + state = get_matching_state (backend_combo.get_active_text(), string(), string()); + if (state) { + return state; + } + state.reset(new StateStruct); + state->backend = get_backend (); + } else { + state.reset(new StateStruct); + store_state (state); } - State state (new StateStruct); - store_state (state); for (StateList::iterator i = states.begin(); i != states.end();) { if ((*i)->backend == state->backend && @@ -1282,7 +1332,7 @@ EngineControl::set_state (const XMLNode& root) state->midi_devices.clear(); XMLNode* midinode; - if ((midinode = find_named_node (*grandchild, "MIDIDevices")) != 0) { + if ((midinode = ARDOUR::find_named_node (*grandchild, "MIDIDevices")) != 0) { const XMLNodeList mnc = midinode->children(); for (XMLNodeList::const_iterator n = mnc.begin(); n != mnc.end(); ++n) { if ((*n)->property (X_("name")) == 0 @@ -1324,6 +1374,21 @@ EngineControl::set_state (const XMLNode& root) /* now see if there was an active state and switch the setup to it */ + // purge states of backend that are not available in this built + vector backends = ARDOUR::AudioEngine::instance()->available_backends(); + vector backend_names; + + for (vector::const_iterator i = backends.begin(); i != backends.end(); ++i) { + backend_names.push_back((*i)->name); + } + for (StateList::iterator i = states.begin(); i != states.end();) { + if (std::find(backend_names.begin(), backend_names.end(), (*i)->backend) == backend_names.end()) { + i = states.erase(i); + } else { + ++i; + } + } + for (StateList::const_iterator i = states.begin(); i != states.end(); ++i) { if ((*i)->active) { @@ -1600,26 +1665,26 @@ EngineControl::post_push () * necessary */ - if (_have_control) { - State state = get_saved_state_for_currently_displayed_backend_and_device (); + State state = get_saved_state_for_currently_displayed_backend_and_device (); - if (!state) { - state = save_state (); - assert (state); - } + if (!state) { + state = save_state (); + assert (state); + } - /* all off */ + /* all off */ - for (StateList::iterator i = states.begin(); i != states.end(); ++i) { - (*i)->active = false; - } + 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) - */ + /* mark this one active (to be used next time the dialog is + * shown) + */ - state->active = true; + state->active = true; + if (_have_control) { // XXX manage_control_app_sensitivity (); } @@ -1806,6 +1871,7 @@ EngineControl::on_switch_page (GtkNotebookPage*, guint page_num) } else { if (lm_running) { + end_latency_detection (); ARDOUR::AudioEngine::instance()->stop_latency_detection(); } } @@ -1861,9 +1927,10 @@ EngineControl::check_audio_latency_measurement () } if (solid) { + have_lm_results = true; end_latency_detection (); lm_use_button.set_sensitive (true); - have_lm_results = true; + return false; } lm_results.set_markup (string_compose (results_markup, buf)); @@ -1916,9 +1983,15 @@ EngineControl::check_midi_latency_measurement () } if (solid) { + have_lm_results = true; end_latency_detection (); lm_use_button.set_sensitive (true); - have_lm_results = true; + return false; + } else if (mididm->processed () > 400) { + have_lm_results = false; + end_latency_detection (); + lm_results.set_markup (string_compose (results_markup, _("Timeout - large MIDI jitter."))); + return false; } lm_results.set_markup (string_compose (results_markup, buf)); @@ -1946,13 +2019,6 @@ EngineControl::start_latency_detection () lm_output_channel_combo.set_sensitive (false); lm_running = true; } - - lm_back_button_signal.disconnect(); - if (_measure_midi) { - lm_back_button_signal = lm_back_button.signal_clicked().connect (sigc::bind (sigc::mem_fun (notebook, &Gtk::Notebook::set_current_page), midi_tab)); - } else { - lm_back_button_signal = lm_back_button.signal_clicked().connect (sigc::bind (sigc::mem_fun (notebook, &Gtk::Notebook::set_current_page), 0)); - } } void @@ -1962,8 +2028,6 @@ EngineControl::end_latency_detection () ARDOUR::AudioEngine::instance()->stop_latency_detection (); lm_measure_label.set_text (_("Measure")); if (!have_lm_results) { - lm_results.set_markup (string_compose (results_markup, _("No measurement results yet"))); - } else { lm_use_button.set_sensitive (false); } lm_input_channel_combo.set_sensitive (true); @@ -2067,7 +2131,10 @@ EngineControl::connect_disconnect_click() void EngineControl::calibrate_audio_latency () { - _measure_midi.reset(); + _measure_midi.reset (); + have_lm_results = false; + lm_use_button.set_sensitive (false); + lm_results.set_markup (string_compose (results_markup, _("No measurement results yet"))); notebook.set_current_page (latency_tab); } @@ -2075,6 +2142,9 @@ void EngineControl::calibrate_midi_latency (MidiDeviceSettings s) { _measure_midi = s; + have_lm_results = false; + lm_use_button.set_sensitive (false); + lm_results.set_markup (string_compose (results_markup, _("No measurement results yet"))); notebook.set_current_page (latency_tab); }