Fix potential underflow issue with vorbis consumer resulting in audio gaps and clicks

presentation
Ulrich Huber 7 years ago
parent 7625ac7530
commit 99d89dcb6e
  1. 4
      src/util/audio/VorbisConsumer.cpp

@ -48,7 +48,7 @@ bool VorbisConsumer::start(string filename)
{
audioQueue->waitForProducer(lock);
while (!audioQueue->empty())
while (audioQueue->size() > 64 * channels || (audioQueue->hasStreamEnded() && !audioQueue->empty()))
{
this->audioQueue->pop(buffer, bufferLength, 64 * channels);
@ -61,7 +61,7 @@ bool VorbisConsumer::start(string filename)
}
}
sf_writef_float(sfFile, buffer, 64);
sf_writef_float(sfFile, buffer, std::min<size_t>(bufferLength / channels, 64));
}
}

Loading…
Cancel
Save