diff --git a/samplebuffer.cpp b/samplebuffer.cpp index 3cc9ec2..3c81d53 100644 --- a/samplebuffer.cpp +++ b/samplebuffer.cpp @@ -18,6 +18,7 @@ */ #include +#include #include "samplebuffer.h" template @@ -35,14 +36,17 @@ SampleBuffer::~SampleBuffer() template std::unique_ptr SampleBuffer::getSamples(off_t start, off_t length) { - auto margin = std::min(start, 128L); - auto samples = src->getSamples(start - margin, length + margin); + // TODO: base this on the actual history required + auto history = std::min(start, 256L); + auto samples = src->getSamples(start - history, length + history); if (samples == nullptr) return nullptr; + std::unique_ptr temp(new Tout[history + length]); std::unique_ptr dest(new Tout[length]); QMutexLocker ml(&mutex); - work(samples.get() + margin, dest.get(), length, start); + work(samples.get(), temp.get(), history + length, start); + memcpy(dest.get(), temp.get() + history, length * sizeof(Tout)); return dest; }