From b330dc23946ecfae91301ababebbfddc97560c7e Mon Sep 17 00:00:00 2001
From: mazmazz <mar.marcoz@outlook.com>
Date: Fri, 14 Sep 2018 16:39:10 -0400
Subject: [PATCH] Don't call I_StartupSound in SFX toggle

* Mixer: make I_StartupSound return early if already set up
* Restartaudio: Add StopSFX call
---
 src/d_netcmd.c        | 1 +
 src/m_menu.c          | 1 -
 src/sdl/mixer_sound.c | 5 ++++-
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/d_netcmd.c b/src/d_netcmd.c
index ab3201c5c1..a58aff3fed 100644
--- a/src/d_netcmd.c
+++ b/src/d_netcmd.c
@@ -3955,6 +3955,7 @@ static void Command_RestartAudio_f(void)
 		return;
 
 	S_StopMusic();
+	S_StopSounds();
 	I_ShutdownMusic();
 	I_ShutdownSound();
 	I_StartupSound();
diff --git a/src/m_menu.c b/src/m_menu.c
index 63794c529b..c9adbfb9c9 100644
--- a/src/m_menu.c
+++ b/src/m_menu.c
@@ -6953,7 +6953,6 @@ static void M_ToggleSFX(void)
 	if (sound_disabled)
 	{
 		sound_disabled = false;
-		I_StartupSound();
 		S_InitSfxChannels(cv_soundvolume.value);
 		S_StartSound(NULL, sfx_strpst);
 		M_StartMessage(M_GetText("SFX Enabled\n"), NULL, MM_NOTHING);
diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c
index f39d375efd..72217482fa 100644
--- a/src/sdl/mixer_sound.c
+++ b/src/sdl/mixer_sound.c
@@ -82,7 +82,10 @@ void I_StartupSound(void)
 
 	// EE inits audio first so we're following along.
 	if (SDL_WasInit(SDL_INIT_AUDIO) == SDL_INIT_AUDIO)
-		CONS_Printf("SDL Audio already started\n");
+	{
+		CONS_Debug(DBG_DETAILED, "SDL Audio already started\n");
+		return;
+	}
 	else if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0)
 	{
 		CONS_Alert(CONS_ERROR, "Error initializing SDL Audio: %s\n", SDL_GetError());
-- 
GitLab