SDL_mixer: quit: Destroy all mixers, then all audiodecoders, then all audios.

From bd894079cd313791a9337dd6be09818826994c66 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Tue, 2 Jun 2026 14:08:50 -0400
Subject: [PATCH] quit: Destroy all mixers, then all audiodecoders, then all
 audios.

Mixers first, so callbacks stop before destroying anything else, AudioDecoders
next because they use MIX_Audio internally, which are then destroyed last,
when the list no longer contains the ones that any AudioDecoders were using.

Reference Issue #861.
---
 src/SDL_mixer.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/SDL_mixer.c b/src/SDL_mixer.c
index 5a901ed7..d9ffd135 100644
--- a/src/SDL_mixer.c
+++ b/src/SDL_mixer.c
@@ -725,14 +725,15 @@ void MIX_Quit(void)
     }
 
     // actually shutting down now.
-    while (all_audiodecoders) {
-        MIX_DestroyAudioDecoder(all_audiodecoders);
-    }
 
     while (all_mixers) {
         MIX_DestroyMixer(all_mixers);
     }
 
+    while (all_audiodecoders) {
+        MIX_DestroyAudioDecoder(all_audiodecoders);
+    }
+
     while (all_audios) {
         MIX_DestroyAudio(all_audios);
     }