mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-05-03 15:32:45 +00:00
s_sound.c: consolidate music volume related functions, always use cvars internally
This commit is contained in:
parent
472f7d060c
commit
acbe0b270c
4 changed files with 20 additions and 27 deletions
|
|
@ -1659,8 +1659,8 @@ void D_SRB2Main(void)
|
||||||
CONS_Printf("S_InitSfxChannels(): Setting up sound channels.\n");
|
CONS_Printf("S_InitSfxChannels(): Setting up sound channels.\n");
|
||||||
I_StartupSound();
|
I_StartupSound();
|
||||||
I_InitMusic();
|
I_InitMusic();
|
||||||
S_InitSfxChannels(cv_soundvolume.value);
|
S_InitSfxChannels();
|
||||||
S_InitMusicVolume();
|
S_SetMusicVolume();
|
||||||
}
|
}
|
||||||
|
|
||||||
Music_Init();
|
Music_Init();
|
||||||
|
|
|
||||||
|
|
@ -667,9 +667,9 @@ void S_UpdateSounds(void)
|
||||||
|
|
||||||
// Update sound/music volumes, if changed manually at console
|
// Update sound/music volumes, if changed manually at console
|
||||||
if (actualsfxvolume != cv_soundvolume.value)
|
if (actualsfxvolume != cv_soundvolume.value)
|
||||||
S_SetSfxVolume (cv_soundvolume.value);
|
S_SetSfxVolume();
|
||||||
if (actualdigmusicvolume != cv_digmusicvolume.value)
|
if (actualdigmusicvolume != cv_digmusicvolume.value)
|
||||||
S_SetDigMusicVolume (cv_digmusicvolume.value);
|
S_SetMusicVolume();
|
||||||
|
|
||||||
// We're done now, if we're not in a level.
|
// We're done now, if we're not in a level.
|
||||||
if (gamestate != GS_LEVEL)
|
if (gamestate != GS_LEVEL)
|
||||||
|
|
@ -852,13 +852,12 @@ void S_UpdateClosedCaptions(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void S_SetSfxVolume(INT32 volume)
|
void S_SetSfxVolume(void)
|
||||||
{
|
{
|
||||||
//CV_SetValue(&cv_soundvolume, volume);
|
actualsfxvolume = cv_soundvolume.value;
|
||||||
actualsfxvolume = volume;
|
|
||||||
|
|
||||||
// now hardware volume
|
// now hardware volume
|
||||||
I_SetSfxVolume(volume);
|
I_SetSfxVolume(actualsfxvolume);
|
||||||
}
|
}
|
||||||
|
|
||||||
void S_ClearSfx(void)
|
void S_ClearSfx(void)
|
||||||
|
|
@ -1149,7 +1148,7 @@ void S_StartSoundName(void *mo, const char *soundname)
|
||||||
// Sets channels, SFX volume,
|
// Sets channels, SFX volume,
|
||||||
// allocates channel buffer, sets S_sfx lookup.
|
// allocates channel buffer, sets S_sfx lookup.
|
||||||
//
|
//
|
||||||
void S_InitSfxChannels(INT32 sfxVolume)
|
void S_InitSfxChannels(void)
|
||||||
{
|
{
|
||||||
extern consvar_t precachesound;
|
extern consvar_t precachesound;
|
||||||
|
|
||||||
|
|
@ -1158,7 +1157,7 @@ void S_InitSfxChannels(INT32 sfxVolume)
|
||||||
if (dedicated)
|
if (dedicated)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
S_SetSfxVolume(sfxVolume);
|
S_SetSfxVolume();
|
||||||
|
|
||||||
SetChannelsNum();
|
SetChannelsNum();
|
||||||
|
|
||||||
|
|
@ -2010,14 +2009,10 @@ void S_ResumeAudio(void)
|
||||||
Music_UnPauseAll();
|
Music_UnPauseAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void S_SetMusicVolume(INT32 digvolume)
|
void S_SetMusicVolume(void)
|
||||||
{
|
{
|
||||||
if (digvolume < 0)
|
actualdigmusicvolume = cv_digmusicvolume.value;
|
||||||
digvolume = cv_digmusicvolume.value;
|
I_SetMusicVolume(actualdigmusicvolume);
|
||||||
|
|
||||||
//CV_SetValue(&cv_digmusicvolume, digvolume);
|
|
||||||
actualdigmusicvolume = digvolume;
|
|
||||||
I_SetMusicVolume(digvolume);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ------------------------
|
/// ------------------------
|
||||||
|
|
@ -2138,8 +2133,8 @@ static void Command_RestartAudio_f(void)
|
||||||
|
|
||||||
// These must be called or no sound and music until manually set.
|
// These must be called or no sound and music until manually set.
|
||||||
|
|
||||||
I_SetSfxVolume(cv_soundvolume.value);
|
S_SetSfxVolume();
|
||||||
S_SetMusicVolume(cv_digmusicvolume.value);
|
S_SetMusicVolume();
|
||||||
|
|
||||||
S_StartSound(NULL, sfx_strpst);
|
S_StartSound(NULL, sfx_strpst);
|
||||||
|
|
||||||
|
|
@ -2311,7 +2306,7 @@ void GameSounds_OnChange(void)
|
||||||
{
|
{
|
||||||
sound_disabled = false;
|
sound_disabled = false;
|
||||||
I_StartupSound(); // will return early if initialised
|
I_StartupSound(); // will return early if initialised
|
||||||
S_InitSfxChannels(cv_soundvolume.value);
|
S_InitSfxChannels();
|
||||||
S_StartSound(NULL, sfx_strpst);
|
S_StartSound(NULL, sfx_strpst);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -2350,7 +2345,7 @@ void PlayMusicIfUnfocused_OnChange(void)
|
||||||
if (cv_playmusicifunfocused.value)
|
if (cv_playmusicifunfocused.value)
|
||||||
I_SetMusicVolume(0);
|
I_SetMusicVolume(0);
|
||||||
else
|
else
|
||||||
S_InitMusicVolume();
|
S_SetMusicVolume();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ void S_RegisterSoundStuff(void);
|
||||||
// Initializes sound stuff, including volume
|
// Initializes sound stuff, including volume
|
||||||
// Sets channels, SFX, allocates channel buffer, sets S_sfx lookup.
|
// Sets channels, SFX, allocates channel buffer, sets S_sfx lookup.
|
||||||
//
|
//
|
||||||
void S_InitSfxChannels(INT32 sfxVolume);
|
void S_InitSfxChannels(void);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Per level startup code.
|
// Per level startup code.
|
||||||
|
|
@ -237,10 +237,8 @@ FUNCMATH fixed_t S_CalculateSoundDistance(fixed_t px1, fixed_t py1, fixed_t pz1,
|
||||||
|
|
||||||
INT32 S_GetSoundVolume(sfxinfo_t *sfx, INT32 volume);
|
INT32 S_GetSoundVolume(sfxinfo_t *sfx, INT32 volume);
|
||||||
|
|
||||||
void S_SetSfxVolume(INT32 volume);
|
void S_SetSfxVolume(void);
|
||||||
void S_SetMusicVolume(INT32 digvolume);
|
void S_SetMusicVolume(void);
|
||||||
#define S_SetDigMusicVolume S_SetMusicVolume
|
|
||||||
#define S_InitMusicVolume() S_SetMusicVolume(-1)
|
|
||||||
|
|
||||||
INT32 S_OriginPlaying(void *origin);
|
INT32 S_OriginPlaying(void *origin);
|
||||||
INT32 S_IdPlaying(sfxenum_t id);
|
INT32 S_IdPlaying(sfxenum_t id);
|
||||||
|
|
|
||||||
|
|
@ -513,7 +513,7 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
|
||||||
// Tell game we got focus back, resume music if necessary
|
// Tell game we got focus back, resume music if necessary
|
||||||
window_notinfocus = false;
|
window_notinfocus = false;
|
||||||
|
|
||||||
S_InitMusicVolume();
|
S_SetMusicVolume();
|
||||||
|
|
||||||
if (!firsttimeonmouse)
|
if (!firsttimeonmouse)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue