]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - snd_dma.c
enable MOVE_ values on PF_tracebox (already enabled on PF_traceline)
[xonotic/darkplaces.git] / snd_dma.c
index 3d5adffe4dffc4acd03c6a2658534f05ddc50ceb..e3b4a09b439aab65cbba8b6072660f897ffb73db 100644 (file)
--- a/snd_dma.c
+++ b/snd_dma.c
@@ -275,7 +275,7 @@ void S_Init(void)
 
 /*
 =========
-S_IsCached
+S_GetCached
 
 =========
 */
@@ -342,9 +342,53 @@ S_TouchSound
 */
 void S_TouchSound (char *name)
 {
-       S_FindName(name);
+       sfx_t *sfx;
+
+       sfx = S_FindName (name);
+
+       // Set the "used" flag for this sound
+       if (sfx != NULL)
+               sfx->flags |= SFXFLAG_USED;
 }
 
+
+/*
+==================
+S_ClearUsed
+
+Reset the "used" flag of all precached sounds
+==================
+*/
+void S_ClearUsed (void)
+{
+       int i;
+
+       for (i = 0; i < num_sfx; i++)
+               known_sfx[i].flags &= ~SFXFLAG_USED;
+}
+
+
+/*
+==================
+S_PurgeUnused
+
+Free all precached sounds without the "used" flag
+==================
+*/
+void S_PurgeUnused (void)
+{
+       int i;
+       sfx_t *sfx;
+
+       for (i = 0; i < num_sfx; i++)
+       {
+               sfx = &known_sfx[i];
+               if (! (sfx->flags & SFXFLAG_USED))
+                       S_UnloadSound (sfx);
+       }
+}
+
+
 /*
 ==================
 S_PrecacheSound
@@ -692,7 +736,8 @@ void S_UpdateAmbientSounds (void)
 // calc ambient sound levels
        for (ambient_channel = 0 ; ambient_channel< NUM_AMBIENTS ; ambient_channel++)
        {
-               if (ambient_sfx[ambient_channel] && ambient_sfx[ambient_channel]->silentlymissing)
+               if (ambient_sfx[ambient_channel] &&
+                       (ambient_sfx[ambient_channel]->flags & SFXFLAG_SILENTLYMISSING))
                        continue;
                chan = &channels[ambient_channel];
                chan->forceloop = true;
@@ -881,7 +926,7 @@ void S_Update_(void)
 
                if (pDSBuf)
                {
-                       if (pDSBuf->lpVtbl->GetStatus (pDSBuf, &dwStatus) != DD_OK)
+                       if (pDSBuf->lpVtbl->GetStatus (pDSBuf, &dwStatus) != DS_OK)
                                Con_Printf ("Couldn't get sound buffer status\n");
 
                        if (dwStatus & DSBSTATUS_BUFFERLOST)
@@ -988,21 +1033,6 @@ void S_LocalSound (char *sound)
 }
 
 
-void S_ClearPrecache (void)
-{
-}
-
-
-void S_BeginPrecaching (void)
-{
-}
-
-
-void S_EndPrecaching (void)
-{
-}
-
-
 #define RAWSAMPLESBUFFER 32768
 short s_rawsamplesbuffer[RAWSAMPLESBUFFER * 2];
 int s_rawsamplesbuffer_start;