Lincoln's patch for latency compensation at punch in/stop, modified to use DEBUG_TRACE
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 4 Jan 2010 19:58:41 +0000 (19:58 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 4 Jan 2010 19:58:41 +0000 (19:58 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@6447 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/debug.cc
libs/ardour/diskstream.cc

index 037007497d1f6ec2fecd7adfeacc8ae891b8e0c7..773dd6d0f61cea4682fba46d08eca9ac73f8f789 100644 (file)
@@ -118,4 +118,5 @@ ARDOUR::list_debug_options ()
        cerr << "\tSlave" << endl;
        cerr << "\tSessionEvents" << endl;
        cerr << "\tMidiIO" << endl;
+       cerr << "\tLatencyCompensation" << endl;
 }
index 7004ef1ed5036bda416584e255107cd7df4a7b35..7920f3b27949f7294963ab9e46da737ce2ee15a7 100644 (file)
@@ -296,7 +296,7 @@ Diskstream::get_captured_frames (uint32_t n)
        if (capture_info.size() > n) {
                return capture_info[n]->frames;
        }
-       else {
+       else {  
                return capture_captured;
        }
 }
@@ -525,7 +525,11 @@ Diskstream::check_record_status (nframes_t transport_frame, nframes_t /*nframes*
                        /* was stopped, now rolling (and recording) */
 
                        if (_alignment_style == ExistingMaterial) {
+                         
                                first_recordable_frame += _session.worst_output_latency();
+                               
+                               DEBUG_TRACE (DEBUG::Latency, string_compose ("Offset rec from stop. Capture offset: %1 Worst O/P Latency: %2 Roll Delay: %3 First Recordable Frame: %4 Transport Frame: %5\n",
+                                                                            _capture_offset, _session.worst_output_latency(), _roll_delay, first_recordable_frame, transport_frame));
                        } else {
                                first_recordable_frame += _roll_delay;
                        }
@@ -536,34 +540,23 @@ Diskstream::check_record_status (nframes_t transport_frame, nframes_t /*nframes*
 
                        if (_alignment_style == ExistingMaterial) {
 
-
-                               if (!_session.config.get_punch_in()) {
-
-                                       /* manual punch in happens at the correct transport frame
-                                          because the user hit a button. but to get alignment correct
-                                          we have to back up the position of the new region to the
-                                          appropriate spot given the roll delay.
-                                       */
-
-                                       capture_start_frame -= _roll_delay;
-
-                                       /* XXX paul notes (august 2005): i don't know why
-                                          this is needed.
-                                       */
-
-                                       first_recordable_frame += _capture_offset;
-
-                               } else {
-
-                                       /* autopunch toggles recording at the precise
-                                          transport frame, and then the DS waits
-                                          to start recording for a time that depends
-                                          on the output latency.
-                                       */
-
-                                       first_recordable_frame += _session.worst_output_latency();
-                               }
-
+                               /* manual punch in happens at the correct transport frame
+                                  because the user hit a button. but to get alignment correct
+                                  we have to back up the position of the new region to the
+                                  appropriate spot given the roll delay.
+                               */
+                               
+                               
+                               /* autopunch toggles recording at the precise
+                                  transport frame, and then the DS waits
+                                  to start recording for a time that depends
+                                  on the output latency.
+                               */
+                               
+                               first_recordable_frame += _session.worst_output_latency();
+                               
+                               DEBUG_TRACE (DEBUG::Latency, string_compose ("Punch in manual/auto. Capture offset: %1 Worst O/P Latency: %2 Roll Delay: %3 First Recordable Frame: %4 Transport Frame: %5\n",
+                                                                            _capture_offset, _session.worst_output_latency(), _roll_delay, first_recordable_frame, transport_frame));
                        } else {
 
                                if (_session.config.get_punch_in()) {
@@ -589,7 +582,11 @@ Diskstream::check_record_status (nframes_t transport_frame, nframes_t /*nframes*
                        last_recordable_frame += _roll_delay;
                }
                
-               first_recordable_frame = max_frames;
+               //first_recordable_frame = max_frames;
+               
+               DEBUG_TRACE (DEBUG::Latency, string_compose ("Stop record - %6 | %7. Capture offset: %1 Worst O/P Latency: %2 Roll Delay: %3 First Recordable Frame: %4 Transport Frame: %5\n",
+                                                            _capture_offset, _session.worst_output_latency(), _roll_delay, first_recordable_frame, transport_frame,
+                                                            can_record, record_enabled()));
        }
 
        last_possibly_recording = possibly_recording;