]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
added snd_reload command to reload all sounds
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 17 Dec 2006 18:14:02 +0000 (18:14 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 17 Dec 2006 18:14:02 +0000 (18:14 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6656 d7cf8633-e32d-0410-b094-e92efae38249

snd_main.c
snd_null.c
sound.h

index 3273355c56b26c7dd0d56c3edf0dc4319f21a585..a6945527c3837fb8b9b2924cf53b4640a485eb50 100644 (file)
@@ -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);
 
index c98440ac23f3b34a68ec60284cb21a0f3125bb87..6eb6b94c4e96f8d8ffd1b51c68fd2c12316c3ea4 100755 (executable)
@@ -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 6bf499e36025eefe41226f994c66285163612e89..fbd5755ba5b40f3f2d59addd9fc903998524250e 100644 (file)
--- 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);