With longer process sizes we can end up with insufficient space in the inbuf, but enough in the outbuf following the previous retrieve call for a consume to be possible before writing to the inbuf

This commit is contained in:
Chris Cannam
2022-09-01 10:41:25 +01:00
parent 53eca719fb
commit 4336d47a02
2 changed files with 6 additions and 0 deletions

View File

@@ -673,6 +673,7 @@ int main(int argc, char **argv)
RubberBandStretcher ts(sfinfo.samplerate, channels, options,
ratio, frequencyshift);
ts.setExpectedInputDuration(sfinfo.frames);
ts.setMaxProcessSize(bs);
int frame = 0;
int percent = 0;

View File

@@ -647,6 +647,11 @@ R3Stretcher::process(const float *const *input, size_t samples, bool final)
}
size_t ws = m_channelData[0]->inbuf->getWriteSpace();
if (samples > ws) {
m_log.log(2, "R3Stretcher::process: insufficient space in input buffer, attempting consume before write");
consume();
ws = m_channelData[0]->inbuf->getWriteSpace();
}
if (samples > ws) {
m_log.log(0, "R3Stretcher::process: WARNING: Forced to increase input buffer size. Either setMaxProcessSize was not properly called or process is being called repeatedly without retrieve. Write space and samples", ws, samples);
size_t newSize = m_channelData[0]->inbuf->getSize() - ws + samples;