summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2011-04-06 17:55:51 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2011-04-06 17:55:51 +0000
commitffbc27b1c3c8b51255856afa8dfd0c50b1e60aa3 (patch)
treeb7fde518be60e2ae3eeceaab77fbed8632af9d92 /libs
parent4b8274b4d43525a6ef5b22c25fdd099afd513556 (diff)
back-port capture offset corrections from 3.0 to 2.0-ongoing. fairly well tested, though not exhaustively
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@9306 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/ardour/session.h1
-rw-r--r--libs/ardour/audio_diskstream.cc71
2 files changed, 9 insertions, 63 deletions
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h
index 2bd8d74bc5..cd7e52cc08 100644
--- a/libs/ardour/ardour/session.h
+++ b/libs/ardour/ardour/session.h
@@ -444,6 +444,7 @@ class Session : public PBD::StatefulDestructible
nframes_t worst_output_latency () const { return _worst_output_latency; }
nframes_t worst_input_latency () const { return _worst_input_latency; }
nframes_t worst_track_latency () const { return _worst_track_latency; }
+ nframes_t worst_playback_latency () const { return _worst_output_latency + _worst_track_latency; }
int save_state (string snapshot_name, bool pending = false, bool switch_to_snapshot = false);
int restore_state (string snapshot_name);
diff --git a/libs/ardour/audio_diskstream.cc b/libs/ardour/audio_diskstream.cc
index 2c87773dbe..4a37c7038c 100644
--- a/libs/ardour/audio_diskstream.cc
+++ b/libs/ardour/audio_diskstream.cc
@@ -397,6 +397,8 @@ AudioDiskstream::check_record_status (nframes_t transport_frame, nframes_t nfram
possibly_recording = (rolling << 2) | (record_enabled() << 1) | can_record;
change = possibly_recording ^ last_possibly_recording;
+ nframes_t existing_material_offset = _session.worst_playback_latency ();
+
if (possibly_recording == fully_rec_enabled) {
if (last_possibly_recording == fully_rec_enabled) {
@@ -405,65 +407,12 @@ AudioDiskstream::check_record_status (nframes_t transport_frame, nframes_t nfram
/* we transitioned to recording. lets see if its transport based or a punch */
- first_recordable_frame = transport_frame + _capture_offset;
+ capture_start_frame = _session.transport_frame();
+ first_recordable_frame = capture_start_frame + _capture_offset;
last_recordable_frame = max_frames;
- capture_start_frame = transport_frame;
-
- if (change & transport_rolling) {
-
- /* transport-change (started rolling) */
-
- if (_alignment_style == ExistingMaterial) {
-
- /* there are two delays happening:
-
- 1) inbound, represented by _capture_offset
- 2) outbound, represented by _session.worst_output_latency()
-
- the first sample to record occurs when the larger of these
- two has elapsed, since they occur in parallel.
-
- since we've already added _capture_offset, just add the
- difference if _session.worst_output_latency() is larger.
- */
-
- if (_capture_offset < _session.worst_output_latency()) {
- first_recordable_frame += (_session.worst_output_latency() - _capture_offset);
- }
- } else {
- first_recordable_frame += _roll_delay;
- }
-
- } else {
- /* punch in */
-
- if (_alignment_style == ExistingMaterial) {
-
- /* There are two kinds of punch:
-
- 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.
-
- XXX: BUT THIS CODE DOESN'T DIFFERENTIATE !!!
-
- */
-
- if (_capture_offset < _session.worst_output_latency()) {
- /* see comment in ExistingMaterial block above */
- first_recordable_frame += (_session.worst_output_latency() - _capture_offset);
- }
-
- } else {
- capture_start_frame -= _roll_delay;
- }
+ if (_alignment_style == ExistingMaterial) {
+ first_recordable_frame += existing_material_offset;
}
if (recordable() && destructive()) {
@@ -499,14 +448,10 @@ AudioDiskstream::check_record_status (nframes_t transport_frame, nframes_t nfram
} else {
/* punch out */
- last_recordable_frame = transport_frame + _capture_offset;
+ last_recordable_frame = _session.transport_frame() + _capture_offset;
if (_alignment_style == ExistingMaterial) {
- if (_session.worst_output_latency() > _capture_offset) {
- last_recordable_frame += (_session.worst_output_latency() - _capture_offset);
- }
- } else {
- last_recordable_frame += _roll_delay;
+ last_recordable_frame += existing_material_offset;
}
}
}