summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2013-09-16 22:11:06 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2013-09-16 22:11:06 -0400
commitfb45fdc052b23f4b2210c71a03a14bdb5986098a (patch)
treeb61c6331bc7699669834600c09dcf1dc3dccd109 /gtk2_ardour
parent0da34e65e3470b1c2298ddf571df6356d0d42bd8 (diff)
parentc8b32e2f8bed225b8f5ceac130eea6632f595492 (diff)
fix conflicts and merge with master
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/ardour_ui.cc4
-rw-r--r--gtk2_ardour/engine_dialog.cc203
-rw-r--r--gtk2_ardour/engine_dialog.h10
-rw-r--r--gtk2_ardour/utils.cc9
4 files changed, 175 insertions, 51 deletions
diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc
index 50a903cf6c..c3d3211db1 100644
--- a/gtk2_ardour/ardour_ui.cc
+++ b/gtk2_ardour/ardour_ui.cc
@@ -4166,9 +4166,7 @@ ARDOUR_UI::do_audio_midi_setup (uint32_t desired_sample_rate)
_audio_midi_setup->set_desired_sample_rate (desired_sample_rate);
- int r = _audio_midi_setup->run ();
-
- switch (r) {
+ switch (_audio_midi_setup->run()) {
case Gtk::RESPONSE_OK:
return 0;
case Gtk::RESPONSE_APPLY:
diff --git a/gtk2_ardour/engine_dialog.cc b/gtk2_ardour/engine_dialog.cc
index d724f4f4d3..5fff838a6f 100644
--- a/gtk2_ardour/engine_dialog.cc
+++ b/gtk2_ardour/engine_dialog.cc
@@ -31,6 +31,7 @@
#include "pbd/xml++.h"
#include "pbd/unwind.h"
+#include <gtkmm/alignment.h>
#include <gtkmm/stock.h>
#include <gtkmm/notebook.h>
#include <gtkmm2ext/utils.h>
@@ -66,14 +67,17 @@ EngineControl::EngineControl ()
, output_channels (output_channels_adjustment)
, ports_adjustment (128, 8, 1024, 1, 16)
, ports_spinner (ports_adjustment)
- , control_app_button (_("Launch Control App"))
- , lm_measure_button (_("Measure latency"))
+ , control_app_button (_("Device Control Panel"))
+ , lm_start_stop_label (_("Measure latency"))
, lm_use_button (_("Use results"))
, lm_table (5, 2)
+ , have_lm_results (false)
, basic_packer (9, 3)
, ignore_changes (0)
, _desired_sample_rate (0)
{
+ set_name (X_("AudioMIDISetup"));
+
build_notebook ();
get_vbox()->set_border_width (12);
@@ -82,9 +86,9 @@ EngineControl::EngineControl ()
control_app_button.signal_clicked().connect (mem_fun (*this, &EngineControl::control_app_button_clicked));
manage_control_app_sensitivity ();
- add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
- add_button (Gtk::Stock::OK, Gtk::RESPONSE_OK);
- add_button (Gtk::Stock::APPLY, Gtk::RESPONSE_APPLY);
+ cancel_button = add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
+ ok_button = add_button (Gtk::Stock::OK, Gtk::RESPONSE_OK);
+ apply_button = add_button (Gtk::Stock::APPLY, Gtk::RESPONSE_APPLY);
/* Pick up any existing audio setup configuration, if appropriate */
@@ -111,6 +115,13 @@ EngineControl::on_response (int response_id)
push_state_to_backend (true);
hide ();
break;
+ case RESPONSE_DELETE_EVENT: {
+ GdkEventButton ev;
+ ev.type = GDK_BUTTON_PRESS;
+ ev.button = 1;
+ on_delete_event ((GdkEventAny*) &ev);
+ break;
+ }
default:
hide ();
}
@@ -168,18 +179,33 @@ EngineControl::build_notebook ()
basic_packer.attach (buffer_size_duration_label, 2, 3, row, row+1, xopt, (AttachOptions) 0);
row++;
+ input_channels.set_name ("InputChannels");
+ input_channels.set_flags(Gtk::CAN_FOCUS);
+ input_channels.set_digits(0);
+ input_channels.set_wrap(false);
+ output_channels.set_editable (true);
label = manage (left_aligned_label (_("Input Channels:")));
basic_packer.attach (*label, 0, 1, row, row+1, xopt, (AttachOptions) 0);
basic_packer.attach (input_channels, 1, 2, row, row+1, xopt, (AttachOptions) 0);
++row;
+ output_channels.set_name ("OutputChannels");
+ output_channels.set_flags(Gtk::CAN_FOCUS);
+ output_channels.set_digits(0);
+ output_channels.set_wrap(false);
+ output_channels.set_editable (true);
label = manage (left_aligned_label (_("Output Channels:")));
basic_packer.attach (*label, 0, 1, row, row+1, xopt, (AttachOptions) 0);
basic_packer.attach (output_channels, 1, 2, row, row+1, xopt, (AttachOptions) 0);
++row;
+ input_latency.set_name ("InputLatency");
+ input_latency.set_flags(Gtk::CAN_FOCUS);
+ input_latency.set_digits(0);
+ input_latency.set_wrap(false);
+ input_latency.set_editable (true);
label = manage (left_aligned_label (_("Hardware input latency:")));
basic_packer.attach (*label, 0, 1, row, row+1, xopt, (AttachOptions) 0);
@@ -188,6 +214,12 @@ EngineControl::build_notebook ()
basic_packer.attach (*label, 2, 3, row, row+1, xopt, (AttachOptions) 0);
++row;
+ output_latency.set_name ("OutputLatency");
+ output_latency.set_flags(Gtk::CAN_FOCUS);
+ output_latency.set_digits(0);
+ output_latency.set_wrap(false);
+ output_latency.set_editable (true);
+
label = manage (left_aligned_label (_("Hardware output latency:")));
basic_packer.attach (*label, 0, 1, row, row+1, xopt, (AttachOptions) 0);
basic_packer.attach (output_latency, 1, 2, row, row+1, xopt, (AttachOptions) 0);
@@ -217,42 +249,75 @@ EngineControl::build_notebook ()
lm_table.attach (lm_title, 0, 2, row, row+1, xopt, (AttachOptions) 0);
row++;
- lm_preamble.set_width_chars (60);
- lm_preamble.set_line_wrap (true);
- lm_preamble.set_markup (_("1. <span weight=\"bold\">Turn down the volume on your hardware to a very low level.</span>\n\n\
-2. Connect the two channels that you select below using either a cable or (less ideally) a speaker \
-and microphone.\n\n\
-3. Once the channels are connected, click the \"Measure latency\" button.\n\n\
-4. When satisfied with the results, click the \"Use results\" button."));
+ Gtk::Label* preamble;
+
+ preamble = manage (new Label);
+ preamble->set_width_chars (60);
+ preamble->set_line_wrap (true);
+ preamble->set_markup (_("<span weight=\"bold\">Turn down the volume on your hardware to a very low level.</span>"));
+
+ lm_table.attach (*preamble, 0, 2, row, row+1, AttachOptions(FILL|EXPAND), (AttachOptions) 0);
+ row++;
+
+ preamble = manage (new Label);
+ preamble->set_width_chars (60);
+ preamble->set_line_wrap (true);
+ preamble->set_markup (_("Select two channels below and connect them using a cable or (less ideally) a speaker and microphone."));
- lm_table.attach (lm_preamble, 0, 2, row, row+1, AttachOptions(FILL|EXPAND), (AttachOptions) 0);
+ lm_table.attach (*preamble, 0, 2, row, row+1, AttachOptions(FILL|EXPAND), (AttachOptions) 0);
row++;
label = manage (new Label (_("Output channel")));
lm_table.attach (*label, 0, 1, row, row+1, xopt, (AttachOptions) 0);
- lm_table.attach (lm_output_channel_combo, 1, 2, row, row+1, xopt, (AttachOptions) 0);
+
+ Gtk::Alignment* misc_align = manage (new Alignment (0.0, 0.5));
+ misc_align->add (lm_output_channel_combo);
+ lm_table.attach (*misc_align, 1, 2, row, row+1, xopt, (AttachOptions) 0);
++row;
label = manage (new Label (_("Input channel")));
lm_table.attach (*label, 0, 1, row, row+1, xopt, (AttachOptions) 0);
- lm_table.attach (lm_input_channel_combo, 1, 2, row, row+1, xopt, (AttachOptions) 0);
+
+ misc_align = manage (new Alignment (0.0, 0.5));
+ misc_align->add (lm_input_channel_combo);
+ lm_table.attach (*misc_align, 1, 2, row, row+1, FILL, (AttachOptions) 0);
++row;
xopt = AttachOptions(0);
+ lm_measure_button.add (lm_start_stop_label);
+
lm_measure_button.signal_toggled().connect (sigc::mem_fun (*this, &EngineControl::latency_button_toggled));
lm_use_button.signal_clicked().connect (sigc::mem_fun (*this, &EngineControl::use_latency_button_clicked));
lm_use_button.set_sensitive (false);
+
+ preamble = manage (new Label);
+ preamble->set_width_chars (60);
+ preamble->set_line_wrap (true);
+ preamble->set_markup (_("Once the channels are connected, click the \"Measure latency\" button."));
+ lm_table.attach (*preamble, 0, 2, row, row+1, AttachOptions(FILL|EXPAND), (AttachOptions) 0);
+ row++;
+
lm_table.attach (lm_measure_button, 0, 2, row, row+1, xopt, (AttachOptions) 0);
++row;
lm_table.attach (lm_results, 0, 2, row, row+1, AttachOptions(FILL|EXPAND), (AttachOptions) 0);
++row;
+
+
+ preamble = manage (new Label);
+ preamble->set_width_chars (60);
+ preamble->set_line_wrap (true);
+ preamble->set_markup (_("When satisfied with the results, click the \"Use results\" button."));
+ lm_table.attach (*preamble, 0, 2, row, row+1, AttachOptions(FILL|EXPAND), (AttachOptions) 0);
+ row++;
+
lm_table.attach (lm_use_button, 0, 2, row, row+1, xopt, (AttachOptions) 0);
++row;
lm_results.set_markup ("<i>No measurement results yet</i>");
+ lm_vbox.set_border_width (12);
lm_vbox.pack_start (lm_table, false, false);
/* pack it all up */
@@ -280,7 +345,6 @@ and microphone.\n\n\
input_channels.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::parameter_changed));
output_channels.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::parameter_changed));
-
input_channels.signal_output().connect (sigc::bind (sigc::ptr_fun (&EngineControl::print_channel_count), &input_channels));
output_channels.signal_output().connect (sigc::bind (sigc::ptr_fun (&EngineControl::print_channel_count), &output_channels));
@@ -316,7 +380,6 @@ EngineControl::enable_latency_tab ()
lm_input_channel_combo.set_active_text (inputs.front());
lm_measure_button.set_sensitive (true);
- lm_use_button.set_sensitive (true);
}
void
@@ -387,8 +450,10 @@ EngineControl::list_devices ()
available_devices.push_back (i->name);
}
+ ignore_changes++;
set_popdown_strings (device_combo, available_devices);
-
+ ignore_changes--;
+
if (!available_devices.empty()) {
sample_rate_combo.set_sensitive (true);
buffer_size_combo.set_sensitive (true);
@@ -464,12 +529,20 @@ EngineControl::device_changed ()
}
}
- set_popdown_strings (sample_rate_combo, s);
- if (desired.empty()) {
- sample_rate_combo.set_active_text (s.front());
+ if (!s.empty()) {
+ set_popdown_strings (sample_rate_combo, s);
+
+ if (desired.empty()) {
+ sample_rate_combo.set_active_text (s.front());
+ } else {
+ sample_rate_combo.set_active_text (desired);
+ }
} else {
- sample_rate_combo.set_active_text (desired);
+ /* hmm ... how to tell the user about the fact that we have no
+ * available sample rates.
+ */
}
+
vector<uint32_t> bs = backend->available_buffer_sizes(device_name);
s.clear ();
@@ -482,9 +555,15 @@ EngineControl::device_changed ()
s.push_back (buf);
}
- set_popdown_strings (buffer_size_combo, s);
- buffer_size_combo.set_active_text (s.front());
- show_buffer_duration ();
+ if (!s.empty()) {
+ set_popdown_strings (buffer_size_combo, s);
+ buffer_size_combo.set_active_text (s.front());
+ show_buffer_duration ();
+ } else {
+ /* hmm ... how to tell the user about the fact that we have no
+ * available buffer sizes.
+ */
+ }
manage_control_app_sensitivity ();
@@ -631,6 +710,10 @@ EngineControl::maybe_display_saved_state ()
sample_rate_combo.set_active_text (state->sample_rate);
}
buffer_size_combo.set_active_text (state->buffer_size);
+ /* call this explicitly because we're ignoring changes to
+ the controls at this point.
+ */
+ show_buffer_duration ();
input_latency.set_value (state->input_latency);
output_latency.set_value (state->output_latency);
ignore_changes--;
@@ -998,9 +1081,19 @@ EngineControl::on_switch_page (GtkNotebookPage*, guint page_num)
if (ARDOUR::AudioEngine::instance()->prepare_for_latency_measurement()) {
disable_latency_tab ();
}
+
enable_latency_tab ();
+
+ cancel_button->set_sensitive (false);
+ ok_button->set_sensitive (false);
+ apply_button->set_sensitive (false);
+
} else {
ARDOUR::AudioEngine::instance()->stop_latency_detection();
+
+ cancel_button->set_sensitive (true);
+ ok_button->set_sensitive (true);
+ apply_button->set_sensitive (true);
}
}
@@ -1010,15 +1103,9 @@ bool
EngineControl::check_latency_measurement ()
{
MTDM* mtdm = ARDOUR::AudioEngine::instance()->mtdm ();
- static uint32_t cnt = 0;
if (mtdm->resolve () < 0) {
- string txt = _("No signal detected ");
- uint32_t dots = cnt++%10;
- for (uint32_t i = 0; i < dots; ++i) {
- txt += '.';
- }
- lm_results.set_text (txt);
+ lm_results.set_markup (string_compose ("<span foreground=\"red\">%1</span>", _("No signal detected ")));
return true;
}
@@ -1058,6 +1145,7 @@ EngineControl::check_latency_measurement ()
lm_measure_button.set_active (false);
lm_use_button.set_sensitive (true);
strcat (buf, " (set)");
+ have_lm_results = true;
}
lm_results.set_text (buf);
@@ -1066,19 +1154,39 @@ EngineControl::check_latency_measurement ()
}
void
-EngineControl::latency_button_toggled ()
+EngineControl::start_latency_detection ()
{
- if (lm_measure_button.get_active ()) {
+ ARDOUR::AudioEngine::instance()->set_latency_input_port (lm_input_channel_combo.get_active_text());
+ ARDOUR::AudioEngine::instance()->set_latency_output_port (lm_output_channel_combo.get_active_text());
+ ARDOUR::AudioEngine::instance()->start_latency_detection ();
+ lm_results.set_text (_("Detecting ..."));
+ latency_timeout = Glib::signal_timeout().connect (mem_fun (*this, &EngineControl::check_latency_measurement), 250);
+ lm_start_stop_label.set_text (_("Cancel measurement"));
+ have_lm_results = false;
+ lm_input_channel_combo.set_sensitive (false);
+ lm_output_channel_combo.set_sensitive (false);
+}
- ARDOUR::AudioEngine::instance()->set_latency_input_port (lm_input_channel_combo.get_active_text());
- ARDOUR::AudioEngine::instance()->set_latency_output_port (lm_output_channel_combo.get_active_text());
- ARDOUR::AudioEngine::instance()->start_latency_detection ();
- lm_results.set_text (_("Detecting ..."));
- latency_timeout = Glib::signal_timeout().connect (mem_fun (*this, &EngineControl::check_latency_measurement), 250);
+void
+EngineControl::end_latency_detection ()
+{
+ ARDOUR::AudioEngine::instance()->stop_latency_detection ();
+ latency_timeout.disconnect ();
+ lm_start_stop_label.set_text (_("Measure latency"));
+ if (!have_lm_results) {
+ lm_results.set_markup ("<i>No measurement results yet</i>");
+ }
+ lm_input_channel_combo.set_sensitive (true);
+ lm_output_channel_combo.set_sensitive (true);
+}
- } else {
- ARDOUR::AudioEngine::instance()->stop_latency_detection ();
- latency_timeout.disconnect ();
+void
+EngineControl::latency_button_toggled ()
+{
+ if (lm_measure_button.get_active ()) {
+ start_latency_detection ();
+ } else {
+ end_latency_detection ();
}
}
@@ -1098,3 +1206,14 @@ EngineControl::use_latency_button_clicked ()
input_latency_adjustment.set_value (one_way);
output_latency_adjustment.set_value (one_way);
}
+
+bool
+EngineControl::on_delete_event (GdkEventAny* ev)
+{
+ if (notebook.get_current_page() == 2) {
+ /* currently on latency tab - be sure to clean up */
+ end_latency_detection ();
+ }
+ return ArdourDialog::on_delete_event (ev);
+}
+
diff --git a/gtk2_ardour/engine_dialog.h b/gtk2_ardour/engine_dialog.h
index 98ddf2c1b3..14724c8bfe 100644
--- a/gtk2_ardour/engine_dialog.h
+++ b/gtk2_ardour/engine_dialog.h
@@ -75,13 +75,18 @@ class EngineControl : public ArdourDialog, public PBD::ScopedConnectionList {
Gtk::ComboBoxText lm_output_channel_combo;
Gtk::ComboBoxText lm_input_channel_combo;
+ Gtk::Label lm_start_stop_label;
Gtk::ToggleButton lm_measure_button;
Gtk::Button lm_use_button;
Gtk::Label lm_title;
- Gtk::Label lm_preamble;
Gtk::Label lm_results;
Gtk::Table lm_table;
Gtk::VBox lm_vbox;
+ bool have_lm_results;
+
+ Gtk::Button* cancel_button;
+ Gtk::Button* ok_button;
+ Gtk::Button* apply_button;
/* JACK specific */
@@ -176,8 +181,11 @@ class EngineControl : public ArdourDialog, public PBD::ScopedConnectionList {
sigc::connection latency_timeout;
void enable_latency_tab ();
void disable_latency_tab ();
+ void start_latency_detection ();
+ void end_latency_detection ();
void on_switch_page (GtkNotebookPage*, guint page_num);
+ bool on_delete_event (GdkEventAny*);
};
#endif /* __gtk2_ardour_engine_dialog_h__ */
diff --git a/gtk2_ardour/utils.cc b/gtk2_ardour/utils.cc
index a35d171690..bbce202ad1 100644
--- a/gtk2_ardour/utils.cc
+++ b/gtk2_ardour/utils.cc
@@ -365,12 +365,11 @@ relay_key_press (GdkEventKey* ev, Gtk::Window* win)
{
PublicEditor& ed (PublicEditor::instance());
- if (&ed == 0) {
- /* early key press in pre-main-window-dialogs, no editor yet */
- return false;
- }
-
if (!key_press_focus_accelerator_handler (*win, ev)) {
+ if (&ed == 0) {
+ /* early key press in pre-main-window-dialogs, no editor yet */
+ return false;
+ }
return ed.on_key_press_event(ev);
} else {
return true;