Never return more than maxSamples from the audio ringbuffer

This commit is contained in:
Ken Cooke 2019-05-23 07:54:08 -07:00
parent bc4a88beb7
commit 0d0a9fbd09

View file

@ -366,8 +366,9 @@ int InboundAudioStream::popSamples(int maxSamples, bool allOrNothing) {
_consecutiveNotMixedCount++;
//Kick PLC to generate a filler frame, reducing 'click'
lostAudioData(allOrNothing ? (maxSamples - samplesAvailable) / _ringBuffer.getNumFrameSamples() : 1);
samplesPopped = _ringBuffer.samplesAvailable();
if (samplesPopped) {
samplesAvailable = _ringBuffer.samplesAvailable();
if (samplesAvailable > 0) {
samplesPopped = std::min(samplesAvailable, maxSamples);
popSamplesNoCheck(samplesPopped);
} else {
// No samples available means a packet is currently being