]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
The first step towards a real CD volume setting (only the fake CD tracks volume are...
authormolivier <molivier@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 11 Apr 2004 17:41:17 +0000 (17:41 +0000)
committermolivier <molivier@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 11 Apr 2004 17:41:17 +0000 (17:41 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4094 d7cf8633-e32d-0410-b094-e92efae38249

cd_shared.c
menu.c
snd_dma.c
snd_null.c
sound.h

index a7919448c805f3fcd4f631cc9341b7495ad5f119..6f15257090413e6da5f7f72a88e5b24d1757c07e 100644 (file)
@@ -109,7 +109,7 @@ void CDAudio_Play (qbyte track, qboolean looping)
        sfx = S_PrecacheSound (va ("cdtracks/track%02u.wav", track), false);
        if (sfx != NULL)
        {
-               faketrack = S_StartSound (-1, 0, sfx, vec3_origin, 1, 0);
+               faketrack = S_StartSound (-1, 0, sfx, vec3_origin, cdvolume, 0);
                if (faketrack != -1)
                {
                        if (looping)
@@ -184,7 +184,7 @@ void CDAudio_Pause (void)
 
 void CDAudio_Resume (void)
 {
-       if (!enabled || !wasPlaying)
+       if (!enabled || cdPlaying || !wasPlaying)
                return;
 
        if (faketrack != -1)
@@ -306,27 +306,39 @@ static void CD_f (void)
        }
 }
 
-void CDAudio_Update (void)
+void CDAudio_SetVolume (float newvol)
 {
-       if (!enabled)
+       // If the volume hasn't changed
+       if (newvol == cdvolume)
                return;
 
-       if (bgmvolume.value != cdvolume)
+       // If the CD has been muted
+       if (newvol == 0.0f)
+               CDAudio_Pause ();
+       else
        {
-               if (cdvolume)
-               {
-                       Cvar_SetValueQuick (&bgmvolume, 0.0);
-                       cdvolume = bgmvolume.value;
-                       CDAudio_Pause ();
-               }
+               // If the CD has been unmuted
+               if (cdvolume == 0.0f)
+                       CDAudio_Resume ();
+
+               if (faketrack != -1)
+                       S_SetChannelVolume (faketrack, newvol);
                else
                {
-                       Cvar_SetValueQuick (&bgmvolume, 1.0);
-                       cdvolume = bgmvolume.value;
-                       CDAudio_Resume ();
+                       // TODO: add support for the "real CD" mixer
                }
        }
 
+       cdvolume = newvol;
+}
+
+void CDAudio_Update (void)
+{
+       if (!enabled)
+               return;
+
+       CDAudio_SetVolume (bgmvolume.value);
+
        if (faketrack == -1)
                CDAudio_SysUpdate();
 }
diff --git a/menu.c b/menu.c
index c486bcb6fcb600afdcf34cdff8eb767942b48cdd..881900c89b14f42ac7dd8ca29338315ed1279fba 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -1216,11 +1216,7 @@ void M_Menu_Options_AdjustSliders (int dir)
        else if (options_cursor == optnum++)
                Cvar_SetValueQuick (&slowmo, bound(0, slowmo.value + dir * 0.25, 5));
        else if (options_cursor == optnum++)
-#ifdef _WIN32
-               Cvar_SetValueQuick (&bgmvolume, bound(0, bgmvolume.value + dir * 1.0, 1));
-#else
                Cvar_SetValueQuick (&bgmvolume, bound(0, bgmvolume.value + dir * 0.1, 1));
-#endif
        else if (options_cursor == optnum++)
                Cvar_SetValueQuick (&volume, bound(0, volume.value + dir * 0.1, 1));
        else if (options_cursor == optnum++)
index 11fb8c326a991da7f51e052e97b0bcd1d0b581c4..c82539c647c43e1110be73422bed94ce98adc2cd 100644 (file)
--- a/snd_dma.c
+++ b/snd_dma.c
@@ -690,6 +690,12 @@ void S_ResumeGameSounds (void)
        }
 }
 
+void S_SetChannelVolume (unsigned int ch_ind, float fvol)
+{
+       channels[ch_ind].master_vol = fvol * 255;
+}
+
+
 void S_ClearBuffer(void)
 {
        int             clear;
index dec82519084467d2770fbb78ea4539669dff8f33..5d43db07acb990e917ab9c6ae9d00f24afb7b095 100755 (executable)
@@ -101,6 +101,10 @@ void S_ResumeGameSounds (void)
 {
 }
 
+void S_SetChannelVolume (unsigned int ch_ind, float fvol)
+{
+}
+
 sfx_t *S_GetCached(const char *name)
 {
        return NULL;
diff --git a/sound.h b/sound.h
index 4d463c2a23519883c8cad633e921b6249f166e1f..55eee7b28da6eafc0f143352b144b5bca9f4d534 100644 (file)
--- a/sound.h
+++ b/sound.h
@@ -112,6 +112,7 @@ void S_StopSound (int entnum, int entchannel);
 void S_StopAllSounds(qboolean clear);
 void S_PauseGameSounds (void);
 void S_ResumeGameSounds (void);
+void S_SetChannelVolume (unsigned int ch_ind, float fvol);
 void S_ClearBuffer (void);
 void S_Update(vec3_t origin, vec3_t forward, vec3_t left, vec3_t up);
 void S_ExtraUpdate (void);
@@ -167,10 +168,8 @@ extern vec3_t listener_viewforward;
 extern vec3_t listener_viewleft;
 extern vec3_t listener_viewup;
 extern volatile dma_t *shm;
-extern volatile dma_t sn;
 extern vec_t sound_nominal_clip_dist;
 
-extern cvar_t loadas8bit;
 extern cvar_t bgmvolume;
 extern cvar_t volume;
 extern cvar_t snd_swapstereo;