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
This commit is contained in:
Paul Davis 2020-03-31 20:51:13 -06:00
parent 370f7bb30f
commit 88e84067f2
2 changed files with 6 additions and 2 deletions

View file

@ -190,6 +190,7 @@ private:
sampleoffset_t _declick_offs; sampleoffset_t _declick_offs;
MidiStateTracker _tracker; MidiStateTracker _tracker;
boost::optional<bool> _last_read_reversed; boost::optional<bool> _last_read_reversed;
boost::optional<bool> _last_read_loop;
static samplecnt_t _chunk_samples; static samplecnt_t _chunk_samples;
static gint _no_disk_output; static gint _no_disk_output;

View file

@ -743,19 +743,20 @@ DiskReader::seek (samplepos_t sample, bool complete_refill)
ChannelList::iterator chan; ChannelList::iterator chan;
boost::shared_ptr<ChannelList> c = channels.reader(); boost::shared_ptr<ChannelList> c = channels.reader();
const bool read_reversed = !_session.transport_will_roll_forwards (); const bool read_reversed = !_session.transport_will_roll_forwards ();
const bool read_loop = (bool) _loop_location;
if (c->empty()) { if (c->empty()) {
return 0; 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 /* We do these things only if we're still reading in the same
* direction we did last time. * direction we did last time.
*/ */
if (sample == playback_sample && !complete_refill) { if (sample == playback_sample && !complete_refill) {
return 0; return 0;
} }
@ -1023,6 +1024,8 @@ DiskReader::audio_read (Sample* sum_buffer,
} }
_last_read_reversed = reversed; _last_read_reversed = reversed;
_last_read_loop = (bool) loc;
return rcnt; return rcnt;
} }