diff options
author | Robin Gareus <robin@gareus.org> | 2020-02-14 18:45:13 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2020-02-14 18:45:13 +0100 |
commit | 4c7cde0242bf47e682cca9190f956973923bcb2d (patch) | |
tree | 6c2495bfbb9e93f18f5ebfa3880e4abc54a053e5 /libs/ardour/disk_reader.cc | |
parent | 1341e18cacd526f4aca831e5ce633d02f93df5a5 (diff) |
Fix seamless looping w/split-cycles
This fixes the following (loop-lennth > internal_playback_seek
length. Due to read-ahead on some cycles the following can happen
---
Loop From: 3528000 To: 3880800 (len: 352800)
start-sample: 3880971 playback_sample: 3528171 nframes: 96
start-sample: 3880875 playback_sample: 3528075 nframes: 192
---
which resulted in disk_samples_to_consume == 0;
Diffstat (limited to 'libs/ardour/disk_reader.cc')
-rw-r--r-- | libs/ardour/disk_reader.cc | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libs/ardour/disk_reader.cc b/libs/ardour/disk_reader.cc index b7d74bdfc5..597541c623 100644 --- a/libs/ardour/disk_reader.cc +++ b/libs/ardour/disk_reader.cc @@ -367,8 +367,14 @@ DiskReader::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp AudioBuffer& disk_buf ((ms & MonitoringInput) ? scratch_bufs.get_audio(n) : output); if (start_sample != playback_sample && target_gain != 0) { - if (can_internal_playback_seek (start_sample - playback_sample)) { - internal_playback_seek (start_sample - playback_sample); + samplepos_t ss = start_sample; + Location* loc = _loop_location; + if (loc) { + Evoral::Range<samplepos_t> loop_range (loc->start(), loc->end() - 1); + ss = loop_range.squish (playback_sample); + } + if (can_internal_playback_seek (ss - playback_sample)) { + internal_playback_seek (ss - playback_sample); } else { disk_samples_to_consume = 0; /* will force an underrun below */ } |