6433ca1736b8 — Chris Cannam 5 days ago
In this emergency, increase the buffer size by a factor rather than only by a constant amount - because if this arises because of an overlong increment being broken down into littler bits, we would end up doing it again and again, which is much more expensive. This makes a huge performance difference in cases where a time map ends up mapping very little input into a great expanse of output
1 files changed, 8 insertions(+), 1 deletions(-)

M src/StretcherProcess.cpp
M src/StretcherProcess.cpp +8 -1
@@ 521,7 521,14 @@ RubberBandStretcher::Impl::processChunkF
         // This is an unhappy situation.
 
         RingBuffer<float> *oldbuf = cd.outbuf;
-        cd.outbuf = oldbuf->resized(oldbuf->getSize() + (required - ws));
+        cd.outbuf = oldbuf->resized(oldbuf->getSize() * 2);
+
+        if (m_debugLevel > 1) {
+            cerr << "(Write space was " << ws << ", needed " << required
+                 << ": resized output buffer from " << oldbuf->getSize()
+                 << " to " << cd.outbuf->getSize() << ")" << endl;
+        }
+
         m_emergencyScavenger.claim(oldbuf);
     }