Improve waiting algorithm for vobis producer when queue reached max size

presentation
Ulrich Huber 7 years ago
parent 59a0eab8fe
commit 7625ac7530
  1. 3
      src/util/audio/VorbisProducer.cpp

@ -36,6 +36,7 @@ bool VorbisProducer::start(std::string filename, unsigned int timestamp)
{
size_t numFrames = 1;
auto sampleBuffer = new float[1024 * this->sfInfo.channels];
std::unique_lock<std::mutex> lock(audioQueue->syncMutex());
while (!this->stopProducer && numFrames > 0 && !this->audioQueue->hasStreamEnded())
{
@ -43,7 +44,7 @@ bool VorbisProducer::start(std::string filename, unsigned int timestamp)
while (this->audioQueue->size() >= this->sample_buffer_size && !this->audioQueue->hasStreamEnded() && !this->stopProducer)
{
std::this_thread::sleep_for(std::chrono::microseconds(100));
audioQueue->waitForConsumer(lock);
}
this->audioQueue->push(sampleBuffer, static_cast<size_t>(numFrames * this->sfInfo.channels));

Loading…
Cancel
Save