From 97445f941a25df089c7bdf7d1b645faaf46e1654 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sun, 29 Oct 2017 01:09:34 -0400 Subject: [PATCH] Add command to restart the audio system --- src/d_netcmd.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index b5563f4e..247829c8 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -26,6 +26,7 @@ #include "p_local.h" #include "p_setup.h" #include "s_sound.h" +#include "i_sound.h" #include "m_misc.h" #include "am_map.h" #include "byteptr.h" @@ -128,6 +129,7 @@ static void Command_Playintro_f(void); static void Command_Displayplayer_f(void); static void Command_Tunes_f(void); +static void Command_RestartAudio_f(void); static void Command_ExitLevel_f(void); static void Command_Showmap_f(void); @@ -670,6 +672,7 @@ void D_RegisterClientCommands(void) COM_AddCommand("displayplayer", Command_Displayplayer_f); COM_AddCommand("tunes", Command_Tunes_f); + COM_AddCommand("restartaudio", Command_RestartAudio_f); CV_RegisterVar(&cv_resetmusic); // FIXME: not to be here.. but needs be done for config loading @@ -3909,6 +3912,20 @@ static void Command_Tunes_f(void) } } +static void Command_RestartAudio_f(void) +{ + I_ShutdownMusic(); + I_ShutdownSound(); + I_StartupSound(); + I_InitMusic(); + +// These must be called or everthing will be muted for the user until next volume change. + + I_SetSfxVolume(cv_soundvolume.value); + I_SetDigMusicVolume(cv_digmusicvolume.value); + I_SetMIDIMusicVolume(cv_midimusicvolume.value); +} + /** Quits a game and returns to the title screen. * */