]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - snd_main.c
replaced Mod_LoadSkinFrame functions with R_SkinFrame system, this
[xonotic/darkplaces.git] / snd_main.c
index a6945527c3837fb8b9b2924cf53b4640a485eb50..d3f16b1193666404f169ed6f1220186df4e3e396 100644 (file)
@@ -167,7 +167,7 @@ cvar_t bgmvolume = {CVAR_SAVE, "bgmvolume", "1", "volume of background music (su
 cvar_t volume = {CVAR_SAVE, "volume", "0.7", "volume of sound effects"};
 cvar_t snd_initialized = { CVAR_READONLY, "snd_initialized", "0", "indicates the sound subsystem is active"};
 cvar_t snd_staticvolume = {CVAR_SAVE, "snd_staticvolume", "1", "volume of ambient sound effects (such as swampy sounds at the start of e1m2)"};
-cvar_t snd_soundradius = {0, "snd_soundradius", "1000", "radius of weapon sounds and other standard sound effects (monster idle noises are half this radius and flickering light noises are one third of this radius)"};
+cvar_t snd_soundradius = {0, "snd_soundradius", "2000", "radius of weapon sounds and other standard sound effects (monster idle noises are half this radius and flickering light noises are one third of this radius)"};
 
 // Cvars declared in snd_main.h (shared with other snd_*.c files)
 cvar_t _snd_mixahead = {CVAR_SAVE, "_snd_mixahead", "0.1", "how much sound to mix ahead of time"};
@@ -708,7 +708,7 @@ void S_Init(void)
        Cvar_RegisterVariable(&snd_channels);
 
 // COMMANDLINEOPTION: Sound: -nosound disables sound (including CD audio)
-       if (COM_CheckParm("-nosound") || COM_CheckParm("-safe"))
+       if (COM_CheckParm("-nosound"))
                return;
 
        snd_mempool = Mem_AllocPool("sound", 0, NULL);
@@ -919,6 +919,9 @@ void S_ServerSounds (char serversound [][MAX_QPATH], unsigned int numsounds)
                sfx = S_FindName (serversound[i]);
                if (sfx != NULL)
                {
+                       // clear the FILEMISSING flag so that S_LoadSound will try again on a
+                       // previously missing file
+                       sfx->flags &= ~ SFXFLAG_FILEMISSING;
                        S_LockSfx (sfx);
                        sfx->flags |= SFXFLAG_SERVERSOUND;
                }
@@ -949,9 +952,14 @@ sfx_t *S_PrecacheSound (const char *name, qboolean complain, qboolean lock)
                return NULL;
 
        sfx = S_FindName (name);
+
        if (sfx == NULL)
                return NULL;
 
+       // clear the FILEMISSING flag so that S_LoadSound will try again on a
+       // previously missing file
+       sfx->flags &= ~ SFXFLAG_FILEMISSING;
+
        if (lock)
                S_LockSfx (sfx);
 
@@ -1282,6 +1290,7 @@ void S_StopSound(int entnum, int entchannel)
                }
 }
 
+extern void CDAudio_Stop(void);
 void S_StopAllSounds (void)
 {
        unsigned int i;
@@ -1394,17 +1403,20 @@ void S_UpdateAmbientSounds (void)
 
                // Don't adjust volume too fast
                // FIXME: this rounds off to an int each frame, meaning there is little to no fade at extremely high framerates!
-               if (chan->master_vol < vol)
-               {
-                       chan->master_vol += (int)(cl.realframetime * ambient_fade.value);
-                       if (chan->master_vol > vol)
-                               chan->master_vol = vol;
-               }
-               else if (chan->master_vol > vol)
+               if (cl.time > cl.oldtime)
                {
-                       chan->master_vol -= (int)(cl.realframetime * ambient_fade.value);
                        if (chan->master_vol < vol)
-                               chan->master_vol = vol;
+                       {
+                               chan->master_vol += (int)((cl.time - cl.oldtime) * ambient_fade.value);
+                               if (chan->master_vol > vol)
+                                       chan->master_vol = vol;
+                       }
+                       else if (chan->master_vol > vol)
+                       {
+                               chan->master_vol -= (int)((cl.time - cl.oldtime) * ambient_fade.value);
+                               if (chan->master_vol < vol)
+                                       chan->master_vol = vol;
+                       }
                }
 
                for (i = 0;i < SND_LISTENERS;i++)
@@ -1419,11 +1431,13 @@ static void S_PaintAndSubmit (void)
        if (snd_renderbuffer == NULL || nosound.integer)
                return;
 
-       if (snd_blocked > 0 && !(cls.capturevideo.soundrate && !cls.capturevideo.realtime))
+       if (snd_blocked > 0 && !cls.timedemo && !(cls.capturevideo.soundrate && !cls.capturevideo.realtime))
                return;
 
        // Update sound time
-       if (cls.capturevideo.soundrate && !cls.capturevideo.realtime) // SUPER NASTY HACK to record non-realtime sound
+       if (cls.timedemo) // SUPER NASTY HACK to mix non-realtime sound for more reliable benchmarking
+               newsoundtime = (unsigned int)((double)cl.mtime[0] * (double)snd_renderbuffer->format.speed);
+       else if (cls.capturevideo.soundrate && !cls.capturevideo.realtime) // SUPER NASTY HACK to record non-realtime sound
                newsoundtime = (unsigned int)((double)cls.capturevideo.frame * (double)snd_renderbuffer->format.speed / (double)cls.capturevideo.framerate);
        else if (simsound)
                newsoundtime = (unsigned int)((realtime - snd_starttime) * (double)snd_renderbuffer->format.speed);
@@ -1492,7 +1506,7 @@ void S_Update(const matrix4x4_t *listenermatrix)
        if (snd_renderbuffer == NULL || nosound.integer)
                return;
 
-       if (snd_blocked > 0 && !(cls.capturevideo.soundrate && !cls.capturevideo.realtime))
+       if (snd_blocked > 0 && !cls.timedemo && !(cls.capturevideo.soundrate && !cls.capturevideo.realtime))
                return;
 
        // If snd_swapstereo or snd_channellayout has changed, recompute the channel layout