13
0

when seeking in disk reader, adjust start of read (if possible) to allow some reverse internal seek allowance

This commit is contained in:
Paul Davis 2020-02-20 00:22:09 -07:00
parent 4037162963
commit c2c41b38d0

View File

@ -776,6 +776,17 @@ DiskReader::seek (samplepos_t sample, bool complete_refill)
(*chan)->rbuf->reset ();
}
/* move the intended read target, so that after the refill is done,
the intended read target is "reservation" from the start of the
playback buffer. Then increment the read ptr, so that we can
potentially do an internal seek backwards of up "reservation"
samples.
*/
const samplecnt_t shift = sample > c->front()->rbuf->reservation_size() ? c->front()->rbuf->reservation_size() : sample;
sample -= shift;
playback_sample = sample;
file_sample[DataType::AUDIO] = sample;
file_sample[DataType::MIDI] = sample;
@ -792,6 +803,16 @@ DiskReader::seek (samplepos_t sample, bool complete_refill)
ret = do_refill_with_alloc (true);
}
sample += shift;
playback_sample = sample;
file_sample[DataType::AUDIO] = sample;
file_sample[DataType::MIDI] = sample;
for (n = 0, chan = c->begin(); chan != c->end(); ++chan, ++n) {
(*chan)->rbuf->increment_read_ptr (shift);
}
return ret;
}