From bef6c2b6653c822ac4bb2b9411bcff80187c7726 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Fri, 14 Sep 2018 21:03:06 -0700 Subject: [PATCH] Fix the underflow caused by the underflow fix :( --- app/streaming/audio/renderers/sdlaud.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/streaming/audio/renderers/sdlaud.cpp b/app/streaming/audio/renderers/sdlaud.cpp index cf705f62..42609480 100644 --- a/app/streaming/audio/renderers/sdlaud.cpp +++ b/app/streaming/audio/renderers/sdlaud.cpp @@ -155,7 +155,14 @@ void SdlAudioRenderer::submitAudio(short* audioBuffer, int audioSize) { m_SampleIndex++; - Uint32 queuedAudio = qMax(SDL_GetQueuedAudioSize(m_AudioDevice) - m_BaselinePendingData, 0U); + Uint32 queuedAudio = SDL_GetQueuedAudioSize(m_AudioDevice); + if (queuedAudio > m_BaselinePendingData) { + queuedAudio -= m_BaselinePendingData; + } + else { + queuedAudio = 0; + } + Uint32 framesQueued = queuedAudio / (SAMPLES_PER_FRAME * m_ChannelCount * sizeof(short)); // We must check this prior to the below checks to ensure we don't