From 73ea38008f8c6b3257cb1131718ea445a7046959 Mon Sep 17 00:00:00 2001
From: Leon Styhre <leon@leonstyhre.com>
Date: Sat, 26 Jun 2021 22:47:21 +0200
Subject: [PATCH] The audio stream is no longer freed on shutdown which avoids
 a random SDL crash bug.

---
 es-core/src/AudioManager.cpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/es-core/src/AudioManager.cpp b/es-core/src/AudioManager.cpp
index f692d3cda..081589364 100644
--- a/es-core/src/AudioManager.cpp
+++ b/es-core/src/AudioManager.cpp
@@ -122,7 +122,12 @@ void AudioManager::init()
 
 void AudioManager::deinit()
 {
-    SDL_FreeAudioStream(sConversionStream);
+    // Due to bugs in SDL, freeing the stream causes random crashes. This is reported to the
+    // user on some operating systems such as macOS, and it's annoying to have a crash at the
+    // end of debugging session. So we'll simply disable the function until it has been properly
+    // fixed in the SDL library.
+//    SDL_FreeAudioStream(sConversionStream);
+
     SDL_CloseAudio();
     SDL_QuitSubSystem(SDL_INIT_AUDIO);
     sInstance = nullptr;