From 4f279557a6f9fa8102a18be26b0be44ccbb6e47e Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 22 Nov 2014 22:28:36 -0800 Subject: Attempt to use BS2B when using headphones without HRTF --- Alc/ALc.c | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) (limited to 'Alc/ALc.c') diff --git a/Alc/ALc.c b/Alc/ALc.c index 8b14746d..17884f89 100644 --- a/Alc/ALc.c +++ b/Alc/ALc.c @@ -1971,6 +1971,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) { bool headphones = false; const char *mode; + int bs2blevel; int usehrtf; if(ConfigValueStr(NULL, "stereo-mode", &mode)) @@ -1988,26 +1989,32 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) if(usehrtf) device->Hrtf = GetHrtf(device->FmtChans, device->Frequency); - if(!device->Hrtf) + if(device->Hrtf) + TRACE("HRTF enabled\n"); + else + { device->Flags &= ~DEVICE_HRTF_REQUEST; - TRACE("HRTF %s\n", device->Hrtf?"enabled":"disabled"); + TRACE("HRTF disabled\n"); - if(!device->Hrtf && device->Bs2bLevel > 0 && device->Bs2bLevel <= 6) - { - if(!device->Bs2b) + bs2blevel = (headphones ? 5 : 0); + ConfigValueInt(NULL, "cf_level", &bs2blevel); + if(bs2blevel > 0 && bs2blevel <= 6) { - device->Bs2b = calloc(1, sizeof(*device->Bs2b)); - bs2b_clear(device->Bs2b); + if(!device->Bs2b) + { + device->Bs2b = calloc(1, sizeof(*device->Bs2b)); + bs2b_clear(device->Bs2b); + } + bs2b_set_srate(device->Bs2b, device->Frequency); + bs2b_set_level(device->Bs2b, bs2blevel); + TRACE("BS2B enabled\n"); + } + else + { + free(device->Bs2b); + device->Bs2b = NULL; + TRACE("BS2B disabled\n"); } - bs2b_set_srate(device->Bs2b, device->Frequency); - bs2b_set_level(device->Bs2b, device->Bs2bLevel); - TRACE("BS2B level %d\n", device->Bs2bLevel); - } - else - { - free(device->Bs2b); - device->Bs2b = NULL; - TRACE("BS2B disabled\n"); } } @@ -3253,7 +3260,6 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) device->Flags = 0; device->Bs2b = NULL; - device->Bs2bLevel = 0; AL_STRING_INIT(device->DeviceName); device->DryBuffer = NULL; @@ -3378,8 +3384,6 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) ConfigValueUInt(NULL, "sends", &device->NumAuxSends); if(device->NumAuxSends > MAX_SENDS) device->NumAuxSends = MAX_SENDS; - ConfigValueInt(NULL, "cf_level", &device->Bs2bLevel); - device->NumStereoSources = 1; device->NumMonoSources = device->MaxNoOfSources - device->NumStereoSources; @@ -3700,7 +3704,6 @@ ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceN device->Flags = 0; device->Bs2b = NULL; - device->Bs2bLevel = 0; AL_STRING_INIT(device->DeviceName); device->DryBuffer = NULL; -- cgit v1.2.3