Don't use idAudioHardware to get the speaker count

Use the CVar s_numberOfSpeakers for that, its already stored
in there.
Add the same (!= 2 && !=6) check as in the audio backends since
the mixer is limited to these 2 values.
This commit is contained in:
dhewg 2011-12-14 16:48:20 +01:00
parent 66141935f5
commit 4e26e1ac6f
2 changed files with 18 additions and 13 deletions

View file

@ -476,6 +476,13 @@ idSoundSystemLocal::InitHW
=============== ===============
*/ */
bool idSoundSystemLocal::InitHW() { bool idSoundSystemLocal::InitHW() {
int numSpeakers = s_numberOfSpeakers.GetInteger();
if (numSpeakers != 2 && numSpeakers != 6) {
common->Warning("invalid value for s_numberOfSpeakers. Use either 2 or 6");
numSpeakers = 2;
s_numberOfSpeakers.SetInteger(numSpeakers);
}
if ( s_noSound.GetBool() ) { if ( s_noSound.GetBool() ) {
return false; return false;
@ -498,10 +505,12 @@ bool idSoundSystemLocal::InitHW() {
if ( snd_audio_hw->GetNumberOfSpeakers() == 0 ) { if ( snd_audio_hw->GetNumberOfSpeakers() == 0 ) {
return false; return false;
} }
// put the real number in there numSpeakers = snd_audio_hw->GetNumberOfSpeakers();
s_numberOfSpeakers.SetInteger( snd_audio_hw->GetNumberOfSpeakers() );
} }
// put the real number in there
s_numberOfSpeakers.SetInteger(numSpeakers);
isInitialized = true; isInitialized = true;
shutdown = false; shutdown = false;
@ -590,7 +599,7 @@ int idSoundSystemLocal::AsyncMix( int soundTime, float *mixBuffer ) {
} }
inTime = Sys_Milliseconds(); inTime = Sys_Milliseconds();
numSpeakers = snd_audio_hw->GetNumberOfSpeakers(); numSpeakers = s_numberOfSpeakers.GetInteger();
// let the active sound world mix all the channels in unless muted or avi demo recording // let the active sound world mix all the channels in unless muted or avi demo recording
if ( !muted && currentSoundWorld && !currentSoundWorld->fpa[0] ) { if ( !muted && currentSoundWorld && !currentSoundWorld->fpa[0] ) {
@ -654,7 +663,7 @@ int idSoundSystemLocal::AsyncUpdate( int inTime ) {
soundStats.runs++; soundStats.runs++;
soundStats.activeSounds = 0; soundStats.activeSounds = 0;
int numSpeakers = snd_audio_hw->GetNumberOfSpeakers(); int numSpeakers = s_numberOfSpeakers.GetInteger();
nextWriteBlock++; nextWriteBlock++;
nextWriteBlock %= ROOM_SLICES_IN_BUFFER; nextWriteBlock %= ROOM_SLICES_IN_BUFFER;
@ -755,7 +764,7 @@ int idSoundSystemLocal::AsyncUpdateWrite( int inTime ) {
} }
int sampleTime = dwCurrentBlock * MIXBUFFER_SAMPLES; int sampleTime = dwCurrentBlock * MIXBUFFER_SAMPLES;
int numSpeakers = snd_audio_hw->GetNumberOfSpeakers(); int numSpeakers = s_numberOfSpeakers.GetInteger();
if ( useOpenAL ) { if ( useOpenAL ) {
// enable audio hardware caching // enable audio hardware caching
@ -837,7 +846,7 @@ cinData_t idSoundSystemLocal::ImageForTime( const int milliseconds, const bool w
float *accum = finalMixBuffer; // unfortunately, these are already clamped float *accum = finalMixBuffer; // unfortunately, these are already clamped
int time = Sys_Milliseconds(); int time = Sys_Milliseconds();
int numSpeakers = snd_audio_hw->GetNumberOfSpeakers(); int numSpeakers = s_numberOfSpeakers.GetInteger();
if ( !waveform ) { if ( !waveform ) {
for( j = 0; j < numSpeakers; j++ ) { for( j = 0; j < numSpeakers; j++ ) {

View file

@ -550,7 +550,7 @@ void idSoundWorldLocal::AVIOpen( const char *path, const char *name ) {
lastAVI44kHz = game44kHz - game44kHz % MIXBUFFER_SAMPLES; lastAVI44kHz = game44kHz - game44kHz % MIXBUFFER_SAMPLES;
if ( soundSystemLocal.snd_audio_hw->GetNumberOfSpeakers() == 6 ) { if ( idSoundSystemLocal::s_numberOfSpeakers.GetInteger() == 6 ) {
fpa[0] = fileSystem->OpenFileWrite( aviDemoPath + "channel_51_left.raw" ); fpa[0] = fileSystem->OpenFileWrite( aviDemoPath + "channel_51_left.raw" );
fpa[1] = fileSystem->OpenFileWrite( aviDemoPath + "channel_51_right.raw" ); fpa[1] = fileSystem->OpenFileWrite( aviDemoPath + "channel_51_right.raw" );
fpa[2] = fileSystem->OpenFileWrite( aviDemoPath + "channel_51_center.raw" ); fpa[2] = fileSystem->OpenFileWrite( aviDemoPath + "channel_51_center.raw" );
@ -581,11 +581,7 @@ void idSoundWorldLocal::AVIUpdate() {
return; return;
} }
if ( !soundSystemLocal.snd_audio_hw ) { numSpeakers = idSoundSystemLocal::s_numberOfSpeakers.GetInteger();
numSpeakers = 2;
} else {
numSpeakers = soundSystemLocal.snd_audio_hw->GetNumberOfSpeakers();
}
float mix[MIXBUFFER_SAMPLES*6+16]; float mix[MIXBUFFER_SAMPLES*6+16];
float *mix_p = (float *)((( intptr_t)mix + 15 ) & ~15); // SIMD align float *mix_p = (float *)((( intptr_t)mix + 15 ) & ~15); // SIMD align
@ -639,7 +635,7 @@ void idSoundWorldLocal::AVIClose( void ) {
fpa[i] = NULL; fpa[i] = NULL;
} }
} }
if ( soundSystemLocal.snd_audio_hw->GetNumberOfSpeakers() == 2 ) { if ( idSoundSystemLocal::s_numberOfSpeakers.GetInteger() == 2 ) {
// convert it to a wave file // convert it to a wave file
idFile *rL, *lL, *wO; idFile *rL, *lL, *wO;
idStr name; idStr name;