diff options
-rw-r--r-- | Alc/ALc.c | 33 | ||||
-rw-r--r-- | Alc/ALu.c | 4 | ||||
-rw-r--r-- | OpenAL32/Include/alMain.h | 8 |
3 files changed, 36 insertions, 9 deletions
@@ -1976,6 +1976,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) } device->Hrtf = NULL; + device->Hrtf_Mode = DisabledHrtf; if(device->FmtChans != DevFmtStereo) { free(device->Bs2b); @@ -1984,20 +1985,35 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) else { bool headphones = device->IsHeadphones; + enum HrtfMode hrtf_mode = FullHrtf; const char *mode; int bs2blevel; int usehrtf; - if(device->Type != Loopback && ConfigValueStr(NULL, "stereo-mode", &mode)) + if(device->Type != Loopback) { - if(strcasecmp(mode, "headphones") == 0) - headphones = true; - else if(strcasecmp(mode, "speakers") == 0) - headphones = false; - else if(strcasecmp(mode, "auto") != 0) - ERR("Unexpected stereo-mode: %s\n", mode); + if(ConfigValueStr(NULL, "stereo-mode", &mode)) + { + if(strcasecmp(mode, "headphones") == 0) + headphones = true; + else if(strcasecmp(mode, "speakers") == 0) + headphones = false; + else if(strcasecmp(mode, "auto") != 0) + ERR("Unexpected stereo-mode: %s\n", mode); + } + + if(ConfigValueStr(NULL, "hrtf-mode", &mode)) + { + if(strcasecmp(mode, "full") == 0) + hrtf_mode = FullHrtf; + else if(strcasecmp(mode, "basic") == 0) + hrtf_mode = BasicHrtf; + else + ERR("Unexpected hrtf-mode: %s\n", mode); + } } + if(device->Type == Loopback || !ConfigValueBool(NULL, "hrtf", &usehrtf)) usehrtf = ((device->Flags&DEVICE_HRTF_REQUEST) || headphones); @@ -2005,6 +2021,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) device->Hrtf = GetHrtf(device->FmtChans, device->Frequency); if(device->Hrtf) { + device->Hrtf_Mode = hrtf_mode; TRACE("HRTF enabled\n"); free(device->Bs2b); device->Bs2b = NULL; @@ -3273,6 +3290,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) device->Flags = 0; device->Bs2b = NULL; + device->Hrtf_Mode = DisabledHrtf; AL_STRING_INIT(device->DeviceName); device->DryBuffer = NULL; @@ -3725,6 +3743,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceN device->Flags = 0; device->Bs2b = NULL; + device->Hrtf_Mode = DisabledHrtf; AL_STRING_INIT(device->DeviceName); device->DryBuffer = NULL; @@ -563,7 +563,7 @@ ALvoid CalcNonAttnSourceParams(ALvoice *voice, const ALsource *ALSource, const A voice->IsHrtf = AL_FALSE; } - else if(Device->Hrtf) + else if(Device->Hrtf_Mode == FullHrtf) { voice->Direct.OutBuffer += voice->Direct.OutChannels; voice->Direct.OutChannels = 2; @@ -999,7 +999,7 @@ ALvoid CalcSourceParams(ALvoice *voice, const ALsource *ALSource, const ALCconte BufferListItem = BufferListItem->next; } - if(Device->Hrtf) + if(Device->Hrtf_Mode == FullHrtf) { /* Use a binaural HRTF algorithm for stereo headphone playback */ aluVector dir = {{ 0.0f, 0.0f, -1.0f, 0.0f }}; diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index 3a79a91b..361af851 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -593,6 +593,13 @@ enum DeviceType { }; +enum HrtfMode { + DisabledHrtf, + BasicHrtf, + FullHrtf +}; + + /* The maximum number of Ambisonics coefficients. For a given order (o), the * size needed will be (o+1)**2, thus zero-order has 1, first-order has 4, * second-order has 9, and third-order has 16. */ @@ -681,6 +688,7 @@ struct ALCdevice_struct /* HRTF filter tables */ const struct Hrtf *Hrtf; + enum HrtfMode Hrtf_Mode; HrtfState Hrtf_State[MAX_OUTPUT_CHANNELS]; HrtfParams Hrtf_Params[MAX_OUTPUT_CHANNELS]; ALuint Hrtf_Offset; |