Merge branch 'restartaudio' into 'master'

Add command to restart the audio system

Closes #27

See merge request STJr/SRB2!214
This commit is contained in:
Monster Iestyn 2017-12-27 16:47:50 -05:00
commit afcdb5cd1e

View file

@ -26,6 +26,7 @@
#include "p_local.h" #include "p_local.h"
#include "p_setup.h" #include "p_setup.h"
#include "s_sound.h" #include "s_sound.h"
#include "i_sound.h"
#include "m_misc.h" #include "m_misc.h"
#include "am_map.h" #include "am_map.h"
#include "byteptr.h" #include "byteptr.h"
@ -128,6 +129,7 @@ static void Command_Playintro_f(void);
static void Command_Displayplayer_f(void); static void Command_Displayplayer_f(void);
static void Command_Tunes_f(void); static void Command_Tunes_f(void);
static void Command_RestartAudio_f(void);
static void Command_ExitLevel_f(void); static void Command_ExitLevel_f(void);
static void Command_Showmap_f(void); static void Command_Showmap_f(void);
@ -670,6 +672,7 @@ void D_RegisterClientCommands(void)
COM_AddCommand("displayplayer", Command_Displayplayer_f); COM_AddCommand("displayplayer", Command_Displayplayer_f);
COM_AddCommand("tunes", Command_Tunes_f); COM_AddCommand("tunes", Command_Tunes_f);
COM_AddCommand("restartaudio", Command_RestartAudio_f);
CV_RegisterVar(&cv_resetmusic); CV_RegisterVar(&cv_resetmusic);
// FIXME: not to be here.. but needs be done for config loading // FIXME: not to be here.. but needs be done for config loading
@ -3941,6 +3944,27 @@ static void Command_Tunes_f(void)
} }
} }
static void Command_RestartAudio_f(void)
{
if (dedicated) // No point in doing anything if game is a dedicated server.
return;
S_StopMusic();
I_ShutdownMusic();
I_ShutdownSound();
I_StartupSound();
I_InitMusic();
// These must be called or no sound and music until manually set.
I_SetSfxVolume(cv_soundvolume.value);
I_SetDigMusicVolume(cv_digmusicvolume.value);
I_SetMIDIMusicVolume(cv_midimusicvolume.value);
if (Playing()) // Gotta make sure the player is in a level
P_RestoreMusic(&players[consoleplayer]);
}
/** Quits a game and returns to the title screen. /** Quits a game and returns to the title screen.
* *
*/ */