From a58e22c543943e280f18e58f49886a993d160310 Mon Sep 17 00:00:00 2001 From: havoc Date: Sun, 17 Dec 2006 18:14:02 +0000 Subject: [PATCH] added snd_reload command to reload all sounds git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6656 d7cf8633-e32d-0410-b094-e92efae38249 --- snd_main.c | 27 +++++++++++++++++++++++++++ snd_null.c | 4 ++++ sound.h | 1 + 3 files changed, 32 insertions(+) diff --git a/snd_main.c b/snd_main.c index 3273355c..a6945527 100644 --- a/snd_main.c +++ b/snd_main.c @@ -724,6 +724,7 @@ void S_Init(void) Cmd_AddCommand("soundlist", S_SoundList_f, "list loaded sounds"); Cmd_AddCommand("soundinfo", S_SoundInfo_f, "print sound system information (such as channels and speed)"); Cmd_AddCommand("snd_restart", S_Restart_f, "restart sound system"); + Cmd_AddCommand("snd_reload", S_Reload_f, "reload all sound files"); Cvar_RegisterVariable(&nosound); Cvar_RegisterVariable(&snd_precache); @@ -770,6 +771,28 @@ void S_Terminate (void) } +/* +================== +S_Reload_f +================== +*/ +void S_Reload_f (void) +{ + int i; + + // stop any active sounds + S_StopAllSounds(); + + // because the ambient sounds will be freed, clear the pointers + for (i = 0;i < (int)sizeof (ambient_sfxs) / (int)sizeof (ambient_sfxs[0]);i++) + ambient_sfxs[i] = NULL; + + // now free all sounds + while (known_sfx != NULL) + S_FreeSfx (known_sfx, true); +} + + /* ================== S_FindName @@ -789,6 +812,7 @@ sfx_t *S_FindName (const char *name) } // Look for this sound in the list of known sfx + // TODO: hash table search? for (sfx = known_sfx; sfx != NULL; sfx = sfx->next) if(!strcmp (sfx->name, name)) return sfx; @@ -1266,6 +1290,9 @@ void S_StopAllSounds (void) if (snd_renderbuffer == NULL) return; + // stop CD audio because it may be using a faketrack + CDAudio_Stop(); + for (i = 0; i < total_channels; i++) S_StopChannel (i); diff --git a/snd_null.c b/snd_null.c index c98440ac..6eb6b94c 100755 --- a/snd_null.c +++ b/snd_null.c @@ -91,6 +91,10 @@ qboolean S_IsSoundPrecached (const sfx_t *sfx) return false; } +void S_Reload_f (void) +{ +} + sfx_t *S_FindName (const char *name) { return NULL; diff --git a/sound.h b/sound.h index 6bf499e3..fbd5755b 100644 --- a/sound.h +++ b/sound.h @@ -60,6 +60,7 @@ void S_Terminate (void); void S_Startup (void); void S_Shutdown (void); +void S_Reload_f (void); void S_Update(const matrix4x4_t *listenermatrix); void S_ExtraUpdate (void); -- 2.39.2