Fix buffer-overflow when vari-speeding

Session::process() can call split-cycle which offset the
buffer pointers. When vari-speeding at speed > 1.0, the
engine also splits the cycle every n_samples, to not exceed
the configured buffersize. This needs to take prior buffer
offsets into account.
This commit is contained in:
Robin Gareus 2019-11-21 23:37:31 +01:00
parent 6ee21fb77e
commit 512c27d277
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -447,11 +447,18 @@ AudioEngine::process_callback (pframes_t nframes)
} else {
pframes_t remain = Port::cycle_nframes ();
while (remain > 0) {
/* keep track of split_cycle() calls by Session::process */
samplecnt_t poff = Port::port_offset ();
pframes_t nf = std::min (remain, nframes);
_session->process (nf);
remain -= nf;
if (remain > 0) {
split_cycle (nf);
/* calculate split-cycle offset */
samplecnt_t delta = Port::port_offset () - poff;
assert (delta >= 0 && delta <= nf);
if (nf > delta) {
split_cycle (nf - delta);
}
}
}
}