diff --git a/src/sound/backend/i_sound.cpp b/src/sound/backend/i_sound.cpp index f2e5759706..cbbed41c10 100644 --- a/src/sound/backend/i_sound.cpp +++ b/src/sound/backend/i_sound.cpp @@ -300,10 +300,7 @@ void I_InitSound () void I_CloseSound () { // Free all loaded samples - for (unsigned i = 0; i < S_sfx.Size(); i++) - { - S_UnloadSound(&S_sfx[i]); - } + S_UnloadAllSounds(); delete GSnd; GSnd = NULL; @@ -339,32 +336,6 @@ const char *GetChannelConfigName(enum ChannelConfig chan) return "(invalid channel config)"; } - -CCMD (snd_status) -{ - GSnd->PrintStatus (); -} - -CCMD (snd_reset) -{ - I_ShutdownMusic(); - S_EvictAllChannels(); - I_CloseSound(); - I_InitSound(); - S_RestartMusic(); - S_RestoreEvictedChannels(); -} - -CCMD (snd_listdrivers) -{ - GSnd->PrintDriversList (); -} - -ADD_STAT (sound) -{ - return GSnd->GatherStats (); -} - SoundRenderer::SoundRenderer () { } diff --git a/src/sound/backend/oalsound.cpp b/src/sound/backend/oalsound.cpp index 12860b8e67..543be26371 100644 --- a/src/sound/backend/oalsound.cpp +++ b/src/sound/backend/oalsound.cpp @@ -2243,7 +2243,7 @@ void OpenALSoundRenderer::UpdateSounds() if(connected == ALC_FALSE) { Printf("Sound device disconnected; restarting...\n"); - AddCommandString("snd_reset"); + S_SoundReset(); return; } } diff --git a/src/sound/s_sound.cpp b/src/sound/s_sound.cpp index c368a97584..d00dc145e9 100644 --- a/src/sound/s_sound.cpp +++ b/src/sound/s_sound.cpp @@ -119,6 +119,7 @@ enum extern float S_GetMusicVolume (const char *music); // PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- +void I_CloseSound(); // PRIVATE FUNCTION PROTOTYPES --------------------------------------------- @@ -2592,3 +2593,41 @@ DEFINE_ACTION_FUNCTION(DObject, S_ResumeSound) return 0; } + +void S_UnloadAllSounds() +{ + for (unsigned i = 0; i < S_sfx.Size(); i++) + { + S_UnloadSound(&S_sfx[i]); + } +} + +CCMD (snd_status) +{ + GSnd->PrintStatus (); +} + +CCMD (snd_reset) +{ + S_SoundReset(); +} + +void S_SoundReset() +{ + I_ShutdownMusic(); + S_EvictAllChannels(); + I_CloseSound(); + I_InitSound(); + S_RestartMusic(); + S_RestoreEvictedChannels(); +} + +CCMD (snd_listdrivers) +{ + GSnd->PrintDriversList (); +} + +ADD_STAT (sound) +{ + return GSnd->GatherStats (); +} diff --git a/src/sound/s_sound.h b/src/sound/s_sound.h index b86c4573ee..5a7e8e0b9d 100644 --- a/src/sound/s_sound.h +++ b/src/sound/s_sound.h @@ -373,5 +373,7 @@ void S_SetEnvironment (const ReverbContainer *settings); ReverbContainer *S_FindEnvironment (const char *name); ReverbContainer *S_FindEnvironment (int id); void S_AddEnvironment (ReverbContainer *settings); +void S_UnloadAllSounds(); +void S_SoundReset(); #endif