]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Added a couple of function skeletons for the automatic unloading of unused sounds...
authormolivier <molivier@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 10 Feb 2004 07:14:03 +0000 (07:14 +0000)
committermolivier <molivier@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 10 Feb 2004 07:14:03 +0000 (07:14 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3884 d7cf8633-e32d-0410-b094-e92efae38249

cl_parse.c
host.c
snd_dma.c
snd_mem.c
snd_null.c
sound.h

index dfe44a9876b55c6c3745dfcadebdd95fbccb74fa..45a8587b82aaac35ed8da3770a631100476641e5 100644 (file)
@@ -405,14 +405,16 @@ void CL_ParseServerInfo (void)
                CL_KeepaliveMessage();
                Mod_TouchModel(parse_model_precache[i]);
        }
+       Mod_PurgeUnused();
+
        // do the same for sounds
+       S_ClearUsed();
        for (i = 1;i < numsounds;i++)
        {
                CL_KeepaliveMessage();
                S_TouchSound(parse_sound_precache[i]);
        }
-       // purge anything that was not touched
-       Mod_PurgeUnused();
+       S_PurgeUnused();
 
        // now we try to load everything that is new
 
@@ -431,13 +433,11 @@ void CL_ParseServerInfo (void)
        }
 
        // sounds
-       S_BeginPrecaching ();
        for (i=1 ; i<numsounds ; i++)
        {
                CL_KeepaliveMessage();
                cl.sound_precache[i] = S_PrecacheSound(parse_sound_precache[i], true);
        }
-       S_EndPrecaching ();
 
        // local state
        ent = &cl_entities[0];
diff --git a/host.c b/host.c
index 09683f911428e8a1e8a976b0e44d1fced119068a..fbb6615a5102821ef211292df56f83b32dd76c28 100644 (file)
--- a/host.c
+++ b/host.c
@@ -577,7 +577,7 @@ qboolean Host_FilterTime (double time)
                {
                        // don't totally hog the CPU
                        if (timeleft >= 0.02)
-                               Sys_Sleep(timeleft * 1000 - 5);
+                               Sys_Sleep((int)(timeleft * 1000) - 5);
                        return false;
                }
        }
index 59f44628a06754dc848b5fa42c738ad4d01bc140..0c785bcc579cc629eb721be273399c49deb19c15 100644 (file)
--- a/snd_dma.c
+++ b/snd_dma.c
@@ -275,7 +275,7 @@ void S_Init(void)
 
 /*
 =========
-S_IsCached
+S_GetCached
 
 =========
 */
@@ -343,8 +343,34 @@ S_TouchSound
 void S_TouchSound (char *name)
 {
        S_FindName(name);
+       // TODO: set the "used" flag for this sound
 }
 
+
+/*
+==================
+S_ClearUsed
+
+==================
+*/
+void S_ClearUsed (void)
+{
+       // TODO: reset the "used" flag of all precached sounds
+}
+
+
+/*
+==================
+S_PurgeUnused
+
+==================
+*/
+void S_PurgeUnused (void)
+{
+       // TODO: free all precached sounds without the "used" flag
+}
+
+
 /*
 ==================
 S_PrecacheSound
@@ -988,21 +1014,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;
index 4e9f5cb53b5080b2451379ecfd4ed6c1699cebe5..5eb1303827815d2c06a00d9eae04b4f64f9d184c 100644 (file)
--- a/snd_mem.c
+++ b/snd_mem.c
@@ -285,8 +285,6 @@ sfxcache_t *S_LoadSound (sfx_t *s, int complain)
        if (s->sfxcache && (s->sfxcache->speed == shm->speed))
                return s->sfxcache;
 
-       s->silentlymissing = !complain;
-
        len = snprintf (namebuffer, sizeof (namebuffer), "sound/%s", s->name);
        if (len >= sizeof (namebuffer))
                return NULL;
@@ -307,6 +305,7 @@ sfxcache_t *S_LoadSound (sfx_t *s, int complain)
                return sc;
 
        // Can't load the sound!
+       s->silentlymissing = !complain;
        if (complain)
        {
                if (modified_name)
index b8627b9218961bf6aea6712f179f9d839fedec0b..68e0171a49eeea1471b48789ec3a8d3552706a3d 100755 (executable)
@@ -82,10 +82,6 @@ sfx_t *S_PrecacheSound (char *sample, int complain)
        return NULL;
 }
 
-void S_ClearPrecache (void)
-{
-}
-
 void S_Update(vec3_t origin, vec3_t forward, vec3_t left, vec3_t up)
 {
 }
@@ -94,14 +90,6 @@ void S_StopAllSounds (qboolean clear)
 {
 }
 
-void S_BeginPrecaching (void)
-{
-}
-
-void S_EndPrecaching (void)
-{
-}
-
 void S_ExtraUpdate (void)
 {
 }
diff --git a/sound.h b/sound.h
index e0ef6c73049e5a2f5acf49c71c5ed22e2b68f857..d0c8418c311c98fef96a76a7f92d0fe4592dc62e 100644 (file)
--- a/sound.h
+++ b/sound.h
@@ -46,7 +46,7 @@ typedef struct sfx_s
        char    name[MAX_QPATH];
        mempool_t       *mempool;
        sfxcache_t      *sfxcache;
-       int silentlymissing; // true if missing and loaded with complain = false
+       qboolean silentlymissing; // true if missing and loaded with complain = false
 } sfx_t;
 
 typedef struct
@@ -100,9 +100,8 @@ void S_ExtraUpdate (void);
 sfx_t *S_GetCached(const char *name);
 sfx_t *S_PrecacheSound (char *sample, int complain);
 void S_TouchSound (char *sample);
-void S_ClearPrecache (void);
-void S_BeginPrecaching (void);
-void S_EndPrecaching (void);
+void S_ClearUsed (void);
+void S_PurgeUnused (void);
 void S_PaintChannels(int endtime);
 void S_InitPaintChannels (void);