diff options
author | Chris Robinson <[email protected]> | 2015-09-04 20:16:48 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2015-09-04 20:16:48 -0700 |
commit | 28a516e8a51ee6a69a2a49b01d54b62bffd9bb43 (patch) | |
tree | 8dd71700d5a50afdbd4457c7c0fd5a01f8a31ad5 | |
parent | 6fc567f1abb760d17b7172e74e8f4652a78078e0 (diff) |
Change the hrtf config option to expect auto/true/false instead of a bool
-rw-r--r-- | Alc/ALc.c | 33 | ||||
-rw-r--r-- | alsoftrc.sample | 9 |
2 files changed, 29 insertions, 13 deletions
@@ -1729,6 +1729,7 @@ static inline void UpdateClockBase(ALCdevice *device) static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) { ALCcontext *context; + ALCenum hrtf_val = ALC_DONT_CARE_SOFT; enum DevFmtChannels oldChans; enum DevFmtType oldType; ALCuint oldFreq; @@ -1919,18 +1920,31 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) UpdateClockBase(device); device->Hrtf_Status = ALC_HRTF_DISABLED_SOFT; - if(device->Type != Loopback && ((device->Flags&DEVICE_HRTF_REQUEST_MASK) == Hrtf_Enable || - GetConfigValueBool(al_string_get_cstr(device->DeviceName), NULL, "hrtf", 0))) + if(device->Type != Loopback) { - if(!FindHrtfFormat(&device->FmtChans, &device->Frequency)) + const char *hrtf; + if(ConfigValueStr(al_string_get_cstr(device->DeviceName), NULL, "hrtf", &hrtf)) { - device->Flags &= ~DEVICE_HRTF_REQUEST_MASK; - device->Hrtf_Status = ALC_HRTF_UNSUPPORTED_FORMAT_SOFT; + if(strcasecmp(hrtf, "true") == 0) + hrtf_val = ALC_TRUE; + else if(strcasecmp(hrtf, "false") == 0) + hrtf_val = ALC_FALSE; + else if(strcasecmp(hrtf, "auto") != 0) + ERR("Unexpected hrtf value: %s\n", hrtf); + } + + if(hrtf_val == ALC_TRUE || (device->Flags&DEVICE_HRTF_REQUEST_MASK) == Hrtf_Enable) + { + if(!FindHrtfFormat(&device->FmtChans, &device->Frequency)) + { + device->Flags &= ~DEVICE_HRTF_REQUEST_MASK; + device->Hrtf_Status = ALC_HRTF_UNSUPPORTED_FORMAT_SOFT; + } + else + device->Flags |= DEVICE_CHANNELS_REQUEST | DEVICE_FREQUENCY_REQUEST; } - else - device->Flags |= DEVICE_CHANNELS_REQUEST | DEVICE_FREQUENCY_REQUEST; } - if(device->Type == Loopback && (device->Flags&DEVICE_HRTF_REQUEST_MASK) == Hrtf_Enable) + else if((device->Flags&DEVICE_HRTF_REQUEST_MASK) == Hrtf_Enable) { enum DevFmtChannels chans = device->FmtChans; ALCuint freq = device->Frequency; @@ -2028,7 +2042,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) } - if(device->Type == Loopback || !ConfigValueBool(al_string_get_cstr(device->DeviceName), NULL, "hrtf", &usehrtf)) + if(hrtf_val == ALC_DONT_CARE_SOFT) { usehrtf = (headphones && (device->Flags&DEVICE_HRTF_REQUEST_MASK) != Hrtf_Disable) || ((device->Flags&DEVICE_HRTF_REQUEST_MASK) == Hrtf_Enable); @@ -2040,6 +2054,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) else { device->Flags &= ~DEVICE_HRTF_REQUEST_MASK; + usehrtf = (hrtf_val == ALC_TRUE); if(!usehrtf) hrtf_status = ALC_HRTF_DENIED_SOFT; else diff --git a/alsoftrc.sample b/alsoftrc.sample index b85e2c3b..af867428 100644 --- a/alsoftrc.sample +++ b/alsoftrc.sample @@ -90,10 +90,11 @@ # Controls HRTF processing. These filters provide better spatialization of # sounds while using headphones, but do require a bit more CPU power. The # default filters will only work with 44100hz or 48000hz stereo output. While -# HRTF is in use, the cf_level option is ignored. Setting this to true or -# false will forcefully enable or disable HRTF, otherwise HRTF will be enabled -# when using headphones. -#hrtf = +# HRTF is used, the cf_level option is ignored. Setting this to auto (default) +# will allow HRTF to be used when headphones are detected or the app requests +# it, while setting true or false will forcefully enable or disable HRTF +# respectively. +#hrtf = auto ## hrtf_tables: (global) # Specifies a comma-separated list of files containing HRTF data sets. The |