From 9d7feaaf9e2e17398b4831866947a455a0f1d97d Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" <icculus@icculus.org> Date: Mon, 6 Nov 2023 09:55:53 -0500 Subject: [PATCH] coreaudio: If paused, clear any pending stream data. This makes sure stuff that was still pending for conversion/resampling doesn't pop in later when the device is unpaused again. Fixes #8485. --- src/audio/coreaudio/SDL_coreaudio.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/audio/coreaudio/SDL_coreaudio.m b/src/audio/coreaudio/SDL_coreaudio.m index 974fe8681..4fb9b7882 100644 --- a/src/audio/coreaudio/SDL_coreaudio.m +++ b/src/audio/coreaudio/SDL_coreaudio.m @@ -532,6 +532,9 @@ static void outputCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBuffe if (!SDL_AtomicGet(&this->enabled) || SDL_AtomicGet(&this->paused)) { /* Supply silence if audio is not enabled or paused */ SDL_memset(inBuffer->mAudioData, this->spec.silence, inBuffer->mAudioDataBytesCapacity); + if (this->stream) { + SDL_AudioStreamClear(this->stream); + } } else if (this->stream) { UInt32 remaining = inBuffer->mAudioDataBytesCapacity; Uint8 *ptr = (Uint8 *)inBuffer->mAudioData;