diff options
-rw-r--r-- | Alc/ALc.c | 20 | ||||
-rw-r--r-- | Alc/ALu.c | 6 | ||||
-rw-r--r-- | Alc/mixer.c | 2 | ||||
-rw-r--r-- | OpenAL32/Include/alMain.h | 13 |
4 files changed, 23 insertions, 18 deletions
@@ -1186,11 +1186,12 @@ static ALCboolean UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) ProcessContext(context); } - device->UseHRTF = AL_FALSE; - if(ChannelsFromDevFmt(device->FmtChans) == 2 && device->Frequency == 44100) - device->UseHRTF = GetConfigValueBool(NULL, "hrtf", AL_FALSE); + device->Flags &= ~DEVICE_USE_HRTF; + if(ChannelsFromDevFmt(device->FmtChans) == 2 && device->Frequency == 44100 && + GetConfigValueBool(NULL, "hrtf", AL_FALSE)) + device->Flags |= DEVICE_USE_HRTF; - if(!device->UseHRTF && device->Bs2bLevel > 0 && device->Bs2bLevel <= 6) + if(!(device->Flags&DEVICE_USE_HRTF) && device->Bs2bLevel > 0 && device->Bs2bLevel <= 6) { if(!device->Bs2b) { @@ -1207,7 +1208,7 @@ static ALCboolean UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) } device->HeadDampen = 0.0f; - if(!device->UseHRTF && ChannelsFromDevFmt(device->FmtChans) <= 2) + if(!(device->Flags&DEVICE_USE_HRTF) && ChannelsFromDevFmt(device->FmtChans) <= 2) { device->HeadDampen = GetConfigValueFloat(NULL, "head_dampen", DEFAULT_HEAD_DAMPEN); device->HeadDampen = __min(device->HeadDampen, 1.0f); @@ -2282,7 +2283,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) device->IsLoopbackDevice = AL_FALSE; device->LastError = ALC_NO_ERROR; - device->UseHRTF = AL_FALSE; + device->Flags = 0; device->Bs2b = NULL; device->szDeviceName = NULL; @@ -2333,7 +2334,8 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) device->Bs2bLevel = GetConfigValueInt(NULL, "cf_level", 0); - device->DuplicateStereo = GetConfigValueBool(NULL, "stereodup", 1); + if(GetConfigValueBool(NULL, "stereodup", AL_TRUE)) + device->Flags |= DEVICE_DUPLICATE_STEREO; device->HeadDampen = 0.0f; @@ -2472,6 +2474,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(void) device->IsLoopbackDevice = AL_TRUE; device->LastError = ALC_NO_ERROR; + device->Flags = 0; device->Bs2b = NULL; device->szDeviceName = NULL; @@ -2508,7 +2511,8 @@ ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(void) device->Bs2bLevel = GetConfigValueInt(NULL, "cf_level", 0); - device->DuplicateStereo = GetConfigValueBool(NULL, "stereodup", 1); + if(GetConfigValueBool(NULL, "stereodup", AL_TRUE)) + device->Flags |= DEVICE_DUPLICATE_STEREO; device->HeadDampen = 0.0f; @@ -87,14 +87,12 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext) ALfloat WetGain[MAX_SENDS]; ALfloat WetGainHF[MAX_SENDS]; ALint NumSends, Frequency; - ALboolean DupStereo; ALfloat Pitch; ALfloat cw; ALint i; /* Get device properties */ DevChans = ALContext->Device->FmtChans; - DupStereo = ALContext->Device->DuplicateStereo; NumSends = ALContext->Device->NumAuxSends; Frequency = ALContext->Device->Frequency; @@ -163,7 +161,7 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext) SrcMatrix[0][FRONT_CENTER] = DryGain * ListenerGain; break; case FmtStereo: - if(DupStereo == AL_FALSE) + if(!(ALContext->Device->Flags&DEVICE_DUPLICATE_STEREO)) { SrcMatrix[0][FRONT_LEFT] = DryGain * ListenerGain; SrcMatrix[1][FRONT_RIGHT] = DryGain * ListenerGain; @@ -670,7 +668,7 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext) Position[2] *= invlen; } - if(Device->UseHRTF) + if((Device->Flags&DEVICE_USE_HRTF)) { const ALshort *hrtf_left, *hrtf_right; diff --git a/Alc/mixer.c b/Alc/mixer.c index e1ecada8..f229b56a 100644 --- a/Alc/mixer.c +++ b/Alc/mixer.c @@ -566,7 +566,7 @@ static void Mix_##T##_##sampler(ALsource *Source, ALCdevice *Device, \ switch(FmtChannels) \ { \ case FmtMono: \ - if(Device->UseHRTF) \ + if((Device->Flags&DEVICE_USE_HRTF)) \ Mix_Hrtf_##T##_1_##sampler(Source, Device, Data, \ DataPosInt, DataPosFrac, \ OutPos, SamplesToDo, BufferSize); \ diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index 9cf2b1a4..09b85baf 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -475,11 +475,8 @@ struct ALCdevice_struct // Simulated dampening from head occlusion ALfloat HeadDampen; - // Duplicate stereo sources on the side/rear channels - ALboolean DuplicateStereo; - - // Use HRTF filters for mixing sounds - ALboolean UseHRTF; + // Device flags + ALuint Flags; // Dry path buffer mix ALfloat DryBuffer[BUFFERSIZE][MAXCHANNELS]; @@ -516,6 +513,12 @@ struct ALCdevice_struct #define ALCdevice_CaptureSamples(a,b,c) ((a)->Funcs->CaptureSamples((a), (b), (c))) #define ALCdevice_AvailableSamples(a) ((a)->Funcs->AvailableSamples((a))) +// Duplicate stereo sources on the side/rear channels +#define DEVICE_DUPLICATE_STEREO (1<<0) +// Use HRTF filters for mixing sounds +#define DEVICE_USE_HRTF (1<<1) + + struct ALCcontext_struct { ALlistener Listener; |