Fix for hang on exit.

Also change fmod to not load if cl_ambientsoun is 0 and made this cvar 0-100 to match the music volume cvar.
This commit is contained in:
pierow 2023-09-07 14:28:49 -04:00
parent 3d5cb0bc6d
commit a4970388ef
4 changed files with 31 additions and 23 deletions

View File

@ -101,7 +101,7 @@ void AvHAmbientSound::UpdateVolume(const Vector& inListenerPosition)
theVolume = this->mVolume - this->mVolume*(theDistance/(float)this->mFadeDistance);
}
float ambientscale = (CVAR_GET_FLOAT("cl_ambientsound"));
float ambientscale = CVAR_GET_FLOAT("cl_ambientsound") * 0.01f;
ambientscale = min(max(0, ambientscale), 1);
theVolume = min(max(0, theVolume), 255);
theVolume *= ambientscale;

View File

@ -6524,7 +6524,9 @@ void AvHHud::UpdateAmbientSounds()
for(AmbientSoundListType::iterator theIter = this->mAmbientSounds.begin(); theIter != this->mAmbientSounds.end(); theIter++)
{
if (CVAR_GET_FLOAT("cl_ambientsound") != 0)
theIter->StartPlayingIfNot();
theIter->UpdateVolume(theListenerPosition);
}
}

View File

@ -530,6 +530,7 @@ int UIHud::Redraw(float flTime, int intermission)
}
// Initialize music the first time through
if (CVAR_GET_FLOAT("cl_ambientsound") != 0)
this->InitializeSound();
}
@ -568,9 +569,10 @@ void UIHud::ShutdownMusic(void)
this->StopInternetStream();
mFMOD->FSOUND_Close();
FMOD_FreeInstance(mFMOD);
////Commented out to fix the dreaded hang on exit! Let HL and the OS take care of it.
//mFMOD->FSOUND_Close();
//
//FMOD_FreeInstance(mFMOD);
mFMOD = NULL;
this->mSoundInitialized = false;
@ -625,9 +627,13 @@ bool UIHud::Update(float inCurrentTime, string& outError)
{
this->mManager.Update(inCurrentTime);
bool theSuccess = true;
if (CVAR_GET_FLOAT("cl_ambientsound") != 0) {
this->UpdateMusic(inCurrentTime);
bool theSuccess = this->UpdateInternetStream(inCurrentTime, outError);
//bool theSuccess = this->UpdateInternetStream(inCurrentTime, outError);
theSuccess = this->UpdateInternetStream(inCurrentTime, outError);
}
return theSuccess;
}

View File

@ -50,7 +50,7 @@ DESCRIPTION INFO_OPTIONS
"cl_ambientsound"
{
"Ambient sound volume (0 to 1)"
"Ambient sound volume (0 to 100)"
{ NUMBER 0.000000 1.000000 }
{ "0.000000" }
}