SDL: coreaudio: Flush/stop the AudioQueue before disposing of it.

From a88aeb2a8a7923209b5f5a5ff15d5d548e8bca12 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Mon, 8 May 2023 14:25:01 -0400
Subject: [PATCH] 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.

(cherry picked from commit 86786ed5447fe32ea2e48f12f0598816a76721c2)
---
 src/audio/coreaudio/SDL_coreaudio.m | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/audio/coreaudio/SDL_coreaudio.m b/src/audio/coreaudio/SDL_coreaudio.m
index 44a11b1a035a..029dd0ea7cb1 100644
--- a/src/audio/coreaudio/SDL_coreaudio.m
+++ b/src/audio/coreaudio/SDL_coreaudio.m
@@ -690,6 +690,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);
     }