From 432e162e762772f5b1fee98705c486e14d1a784e Mon Sep 17 00:00:00 2001 From: molivier Date: Sun, 11 Apr 2004 17:41:17 +0000 Subject: [PATCH] The first step towards a real CD volume setting (only the fake CD tracks volume are correctly supported for the moment). Removed a couple of useless definitions in "sound.h". git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4094 d7cf8633-e32d-0410-b094-e92efae38249 --- cd_shared.c | 40 ++++++++++++++++++++++++++-------------- menu.c | 4 ---- snd_dma.c | 6 ++++++ snd_null.c | 4 ++++ sound.h | 3 +-- 5 files changed, 37 insertions(+), 20 deletions(-) diff --git a/cd_shared.c b/cd_shared.c index a7919448..6f152570 100644 --- a/cd_shared.c +++ b/cd_shared.c @@ -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 c486bcb6..881900c8 100644 --- 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++) diff --git a/snd_dma.c b/snd_dma.c index 11fb8c32..c82539c6 100644 --- 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; diff --git a/snd_null.c b/snd_null.c index dec82519..5d43db07 100755 --- a/snd_null.c +++ b/snd_null.c @@ -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 4d463c2a..55eee7b2 100644 --- 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; -- 2.39.2