diff options
author | Robin Gareus <robin@gareus.org> | 2019-11-21 23:37:31 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2019-11-21 23:37:31 +0100 |
commit | 512c27d27770f6d27b8e10ac606302d784919c35 (patch) | |
tree | cbc7d5e4f855f9d79d42e8385d9820df01fccd43 /libs/ardour/audioengine.cc | |
parent | 6ee21fb77e12ca11f0fc29af9b34a1b64501e5a1 (diff) |
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.
Diffstat (limited to 'libs/ardour/audioengine.cc')
-rw-r--r-- | libs/ardour/audioengine.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc index a491c9cc35..28666cd9db 100644 --- a/libs/ardour/audioengine.cc +++ b/libs/ardour/audioengine.cc @@ -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); + } } } } |