Commit 86786ed5447fe32ea2e48f12f0598816a76721c2

Ryan C. Gordon 2023-05-08T14:25:01

coreaudio: Flush/stop the AudioQueue before disposing of it. Otherwise, a CoreAudio thread lingers forever, and coreaudiod eats CPU until the SDL process terminates. Fixes #7689.

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/src/audio/coreaudio/SDL_coreaudio.m b/src/audio/coreaudio/SDL_coreaudio.m
index 1b2db87..974fe86 100644
--- a/src/audio/coreaudio/SDL_coreaudio.m
+++ b/src/audio/coreaudio/SDL_coreaudio.m
@@ -692,6 +692,8 @@ static void COREAUDIO_CloseDevice(_THIS)
 
     /* dispose of the audio queue before waiting on the thread, or it might stall for a long time! */
     if (this->hidden->audioQueue) {
+        AudioQueueFlush(this->hidden->audioQueue);
+        AudioQueueStop(this->hidden->audioQueue, 0);
         AudioQueueDispose(this->hidden->audioQueue, 0);
     }