fix issues with sound precaching
adds a check if sounds have been previously loaded already also makes it useful at all by not freeing soundsfx data on each mapload when its enabled also adds an onchange so toggling it either caches all sounds again or frees them
This commit is contained in:
1 parent
89b1c316e2
commit
ef08db8d89
3 files changed
+24
-5
No files matched your search
+5
-1
@@ -2936,7 +2936,11 @@ boolean P_SetupLevel(boolean skipprecip)
|
||||
|
||||
// Make sure all sounds are stopped before Z_FreeTags.
|
||||
S_StopSounds();
|
||||
S_ClearSfx();
|
||||
|
||||
if ((!(!sound_disabled && (M_CheckParm("-precachesound")))) || (!precachesound.value)) //why do this with soundprecaching enabled??????
|
||||
{
|
||||
S_ClearSfx();
|
||||
}
|
||||
|
||||
// As oddly named as this is, this handles music only.
|
||||
// We should be fine starting it here.
|
||||
|
||||
+18
-4
@@ -53,6 +53,7 @@ static void Command_ShowMusicCredit_f(void);
|
||||
static void GameMIDIMusic_OnChange(void);
|
||||
#endif
|
||||
static void GameSounds_OnChange(void);
|
||||
static void SoundPrecache_OnChange(void);
|
||||
static void GameDigiMusic_OnChange(void);
|
||||
static void BufferSize_OnChange(void);
|
||||
|
||||
@@ -74,7 +75,7 @@ consvar_t cv_audbuffersize = {"buffersize", "2048", CV_SAVE, audbuffersize_cons_
|
||||
consvar_t stereoreverse = {"stereoreverse", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
// if true, all sounds are loaded at game startup
|
||||
static consvar_t precachesound = {"precachesound", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t precachesound = {"precachesound", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, SoundPrecache_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
// actual general (maximum) sound & music volume, saved into the config
|
||||
consvar_t cv_soundvolume = {"soundvolume", "18", CV_SAVE, soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
@@ -1269,9 +1270,9 @@ void S_InitSfxChannels(INT32 sfxVolume)
|
||||
// Initialize external data (all sounds) at start, keep static.
|
||||
CONS_Printf(M_GetText("Loading sounds... "));
|
||||
|
||||
for (i = 1; i < NUMSFX; i++)
|
||||
if (S_sfx[i].name)
|
||||
S_sfx[i].data = I_GetSfx(&S_sfx[i]);
|
||||
for (i = 1; i < NUMSFX; i++)
|
||||
if (S_sfx[i].name && !S_sfx[i].data)
|
||||
S_sfx[i].data = I_GetSfx(&S_sfx[i]);
|
||||
|
||||
CONS_Printf(M_GetText(" pre-cached all sound data\n"));
|
||||
}
|
||||
@@ -2388,6 +2389,19 @@ void GameSounds_OnChange(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void SoundPrecache_OnChange(void)
|
||||
{
|
||||
if ((precachesound.value) && (!sound_disabled))
|
||||
{
|
||||
S_InitSfxChannels(cv_soundvolume.value);
|
||||
}
|
||||
else if (!precachesound.value)
|
||||
{
|
||||
S_ClearSfx();
|
||||
if (!sound_disabled)
|
||||
S_InitSfxChannels(cv_soundvolume.value);
|
||||
}
|
||||
}
|
||||
|
||||
void GameDigiMusic_OnChange(void)
|
||||
{
|
||||
|
||||
@@ -69,6 +69,7 @@ extern consvar_t cv_resume;
|
||||
extern consvar_t cv_fading;
|
||||
extern consvar_t cv_birdmusic;
|
||||
|
||||
extern consvar_t precachesound;
|
||||
|
||||
extern CV_PossibleValue_t soundvolume_cons_t[];
|
||||
|
||||
|
||||
Reference in new issue
Block a user