mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-13 22:22:05 +00:00
Fix s_noSound logic so it be turned off and on without OpenAL errors or crashes
This commit is contained in:
parent
9e7a717974
commit
8509d80cca
4 changed files with 20 additions and 26 deletions
|
@ -379,7 +379,9 @@ idSoundHardware_OpenAL::Update
|
|||
*/
|
||||
void idSoundHardware_OpenAL::Update()
|
||||
{
|
||||
if( openalDevice == NULL )
|
||||
extern idCVar s_noSound;
|
||||
|
||||
if( openalDevice == NULL && !s_noSound.GetBool() )
|
||||
{
|
||||
int nowTime = Sys_Milliseconds();
|
||||
if( lastResetTime + 1000 < nowTime )
|
||||
|
|
|
@ -580,21 +580,24 @@ void idSoundSample_OpenAL::MakeDefault()
|
|||
playLength = DEFAULT_NUM_SAMPLES;
|
||||
|
||||
|
||||
CheckALErrors();
|
||||
alGenBuffers( 1, &openalBuffer );
|
||||
|
||||
if( CheckALErrors() != AL_NO_ERROR )
|
||||
{
|
||||
common->Error( "idSoundSample_OpenAL::MakeDefault: error generating OpenAL hardware buffer" );
|
||||
}
|
||||
|
||||
if( alIsBuffer( openalBuffer ) )
|
||||
if( soundSystem->GetOpenALDevice() != NULL && !s_noSound.GetBool() )
|
||||
{
|
||||
CheckALErrors();
|
||||
alBufferData( openalBuffer, GetOpenALBufferFormat(), defaultBuffer, totalBufferSize, format.basic.samplesPerSec );
|
||||
alGenBuffers( 1, &openalBuffer );
|
||||
|
||||
if( CheckALErrors() != AL_NO_ERROR )
|
||||
{
|
||||
common->Error( "idSoundSample_OpenAL::MakeDefault: error loading data into OpenAL hardware buffer" );
|
||||
common->Error( "idSoundSample_OpenAL::MakeDefault: error generating OpenAL hardware buffer" );
|
||||
}
|
||||
|
||||
if( alIsBuffer( openalBuffer ) )
|
||||
{
|
||||
CheckALErrors();
|
||||
alBufferData( openalBuffer, GetOpenALBufferFormat(), defaultBuffer, totalBufferSize, format.basic.samplesPerSec );
|
||||
if( CheckALErrors() != AL_NO_ERROR )
|
||||
{
|
||||
common->Error( "idSoundSample_OpenAL::MakeDefault: error loading data into OpenAL hardware buffer" );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -155,9 +155,10 @@ void idSoundSystemLocal::Init()
|
|||
if( !s_noSound.GetBool() )
|
||||
{
|
||||
hardware.Init();
|
||||
InitStreamBuffers();
|
||||
}
|
||||
|
||||
InitStreamBuffers();
|
||||
|
||||
cmdSystem->AddCommand( "testSound", TestSound_f, 0, "tests a sound", idCmdSystem::ArgCompletion_SoundName );
|
||||
cmdSystem->AddCommand( "s_restart", RestartSound_f, 0, "restart sound system" );
|
||||
cmdSystem->AddCommand( "listSamples", ListSamples_f, 0, "lists all loaded sound samples" );
|
||||
|
@ -327,12 +328,6 @@ idSoundSystemLocal::Render
|
|||
*/
|
||||
void idSoundSystemLocal::Render()
|
||||
{
|
||||
|
||||
if( s_noSound.GetBool() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( needsRestart )
|
||||
{
|
||||
needsRestart = false;
|
||||
|
@ -607,12 +602,12 @@ void idSoundSystemLocal::Preload( idPreloadManifest& manifest )
|
|||
const preloadEntry_s& p = manifest.GetPreloadByIndex( ps.idx );
|
||||
filename = p.resourceName;
|
||||
filename.Replace( "generated/", "" );
|
||||
numLoaded++;
|
||||
idSoundSample* sample = LoadSample( filename );
|
||||
if( sample != NULL && !sample->IsLoaded() )
|
||||
{
|
||||
sample->LoadResource();
|
||||
sample->SetLevelLoadReferenced();
|
||||
numLoaded++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -304,12 +304,6 @@ idSoundWorldLocal::Update
|
|||
*/
|
||||
void idSoundWorldLocal::Update()
|
||||
{
|
||||
|
||||
if( s_noSound.GetBool() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// ------------------
|
||||
// Update emitters
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue