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 */
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<uint32_t> protect_ignore_changes (ignore_changes, ignore_changes + 1);
backend_changed ();
}
- maybe_display_saved_state();
/* Connect to signals */
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));
}
ARDOUR::AudioEngine::instance()->get_physical_outputs (type, outputs);
ARDOUR::AudioEngine::instance()->get_physical_inputs (type, inputs);
- if (_measure_midi) {
- lm_preamble.set_markup (_(""));
- } else {
- lm_preamble.set_markup (_("<span weight=\"bold\">Turn down the volume on your audio equipment to a very low level.</span>"));
+ 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;
}
-
- if (inputs.empty() || outputs.empty()) {
+ 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.set_markup (_(""));
} 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.set_markup (_("<span weight=\"bold\">Turn down the volume on your audio equipment to a very low level.</span>"));
}
- 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);
}
{
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);
}
}
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 &&
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
* 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 ();
}
}
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));
}
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;
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
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);