more tweaks to latency measurement
authorPaul Davis <paul@linuxaudiosystems.com>
Wed, 11 Sep 2013 03:25:15 +0000 (23:25 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 11 Sep 2013 03:25:15 +0000 (23:25 -0400)
don't open ports till absolutely necessary (store names for future use).

tidy up parts of the dialog (tab)

gtk2_ardour/engine_dialog.cc
libs/ardour/ardour/audioengine.h
libs/ardour/audioengine.cc

index 8c84c5d3b9003dac336f09b7fe2e89bef122278c..40ce03d77893186e8278da54c5ac0c86b451288d 100644 (file)
@@ -227,23 +227,21 @@ EngineControl::build_notebook ()
 
        lm_preamble.set_width_chars (60);
        lm_preamble.set_line_wrap (true);
-       lm_preamble.set_markup (_("This tool will allow you to <i>precisely</i> measure the signal delay \
-within your audio hardware setup that is not controlled by Ardour or its audio backend.\n\n\
-Connect the two channels that you select below using either a cable or (less ideally) a speaker \
+       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\
-Once the channels are connected, click the \"Measure latency\" button.\n\n\
-When you are satisfied with the results, click the \"Use results\" button to use them with your audio \
-setup parameters. <i>Note: they will not take effect until you restart</i>"));
+3. Once the channels are connected, click the \"Measure latency\" button.\n\n\
+4. When satisfied with the results, click the \"Use results\" button."));
 
        lm_table.attach (lm_preamble, 0, 2, row, row+1, AttachOptions(FILL|EXPAND), (AttachOptions) 0);
        row++;
 
-       label = manage (left_aligned_label (_("Output channel")));
+       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);
        ++row;
 
-       label = manage (left_aligned_label (_("Input channel")));
+       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);
        ++row;
@@ -251,7 +249,8 @@ setup parameters. <i>Note: they will not take effect until you restart</i>"));
        xopt = AttachOptions(0);
 
        lm_measure_button.signal_toggled().connect (sigc::mem_fun (*this, &EngineControl::latency_button_toggled));
-
+       lm_use_button.set_sensitive (false);
+               
        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);
@@ -259,7 +258,7 @@ setup parameters. <i>Note: they will not take effect until you restart</i>"));
        lm_table.attach (lm_use_button, 0, 2, row, row+1, xopt, (AttachOptions) 0);
        ++row;
 
-       lm_results.set_text ("Measured results: 786 samples");
+       lm_results.set_markup ("<i>No measurement results yet</i>");
 
        lm_vbox.pack_start (lm_table, false, false);
 
@@ -974,7 +973,6 @@ EngineControl::check_latency_measurement ()
        static uint32_t cnt = 0;
 
         if (mtdm->resolve () < 0) {
-               cerr << "no resolution\n";
                string txt = _("No signal detected ");
                uint32_t dots = cnt++%10;
                for (uint32_t i = 0; i < dots; ++i) {
@@ -1015,6 +1013,7 @@ EngineControl::check_latency_measurement ()
         if (solid) {
                 // _pi->set_measured_latency (rint (mtdm->del()));
                 lm_measure_button.set_active (false);
+               lm_use_button.set_sensitive (true);
                 strcat (buf, " (set)");
         }
        
index 980f507be59823836b9dfade50172c71c90fecf9..c9d789d7468fea7adeea0a30f6c5e6242bead840 100644 (file)
@@ -220,6 +220,8 @@ public:
     PortEngine::PortHandle    _latency_input_port;
     PortEngine::PortHandle    _latency_output_port;
     framecnt_t                _latency_flush_frames;
+    std::string               _latency_input_name;
+    std::string               _latency_output_name;
 
     void meter_thread ();
     void start_metering_thread ();
index 09478e7ef7bad6bc5bb58964a41b9b410dea26a9..249fd4200ddd8530bbf2c4b0754c57fca058a1b7 100644 (file)
@@ -985,11 +985,37 @@ AudioEngine::mtdm()
 void
 AudioEngine::start_latency_detection ()
 {
+       PortEngine& pe (port_engine());
+
        delete _mtdm;
+       _mtdm = 0;
+
+       /* create the ports we will use to read/write data */
+       
+       if ((_latency_output_port = pe.register_port ("latency_out", DataType::AUDIO, IsOutput)) == 0) {
+               return;
+       }
+       if (pe.connect (_latency_output_port, _latency_output_name)) {
+               return;
+       }
+
+       const string portname ("latency_in");
+       if ((_latency_input_port = pe.register_port (portname, DataType::AUDIO, IsInput)) == 0) {
+               pe.unregister_port (_latency_output_port);
+               return;
+       }
+       if (pe.connect (_latency_input_name, make_port_name_non_relative (portname))) {
+               pe.unregister_port (_latency_output_port);
+               return;
+       }
+       
+       /* all created and connected, lets go */
 
        _mtdm = new MTDM (sample_rate());
        _measuring_latency = true;
         _latency_flush_frames = samples_per_cycle();
+
+
 }
 
 void
@@ -1003,14 +1029,11 @@ AudioEngine::stop_latency_detection ()
 void
 AudioEngine::set_latency_output_port (const string& name)
 {
-       _latency_output_port = port_engine().register_port ("latency_out", DataType::AUDIO, IsOutput);
-       port_engine().connect (_latency_output_port, name);
+       _latency_output_name = name;
 }
 
 void
 AudioEngine::set_latency_input_port (const string& name)
 {
-       const string portname ("latency_in");
-       _latency_input_port = port_engine().register_port (portname, DataType::AUDIO, IsInput);
-       port_engine().connect (name, make_port_name_non_relative (portname));
+       _latency_input_name = name;
 }