From 88e84067f29e5afb8a5a165988c9f46a5964a42f Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 31 Mar 2020 20:51:13 -0600 Subject: [PATCH] if a locate brings us within a heuristic-specified distance of the current position in a DiskReader, pay attention to loop status If the last read was not looped, but the new one should be, we need to ignore the heuristic. Ditto for vice-versa. This isomorphic with the read-reversed case --- libs/ardour/ardour/disk_reader.h | 1 + libs/ardour/disk_reader.cc | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/libs/ardour/ardour/disk_reader.h b/libs/ardour/ardour/disk_reader.h index b0a6f47607..ffd4e2a875 100644 --- a/libs/ardour/ardour/disk_reader.h +++ b/libs/ardour/ardour/disk_reader.h @@ -190,6 +190,7 @@ private: sampleoffset_t _declick_offs; MidiStateTracker _tracker; boost::optional _last_read_reversed; + boost::optional _last_read_loop; static samplecnt_t _chunk_samples; static gint _no_disk_output; diff --git a/libs/ardour/disk_reader.cc b/libs/ardour/disk_reader.cc index 02805c3bcd..0eba91d3d2 100644 --- a/libs/ardour/disk_reader.cc +++ b/libs/ardour/disk_reader.cc @@ -743,19 +743,20 @@ DiskReader::seek (samplepos_t sample, bool complete_refill) ChannelList::iterator chan; boost::shared_ptr c = channels.reader(); const bool read_reversed = !_session.transport_will_roll_forwards (); + const bool read_loop = (bool) _loop_location; if (c->empty()) { return 0; } - if (_last_read_reversed && (_last_read_reversed == read_reversed)) { + if ((!_last_read_reversed && (_last_read_reversed != read_reversed)) || + (!_last_read_loop && (_last_read_loop != read_loop))) { /* We do these things only if we're still reading in the same * direction we did last time. */ if (sample == playback_sample && !complete_refill) { - return 0; } @@ -1023,6 +1024,8 @@ DiskReader::audio_read (Sample* sum_buffer, } _last_read_reversed = reversed; + _last_read_loop = (bool) loc; + return rcnt; }