diff options
author | Chris Robinson <[email protected]> | 2015-07-06 12:37:21 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2015-07-06 12:37:21 -0700 |
commit | 8fa4f276f89985be44007ce166109837cbfd5763 (patch) | |
tree | b0342cbe526acea3e1cec4f121c53d57ab921b10 | |
parent | f58d985789f86ff11d1e2d1dda53801f447e2736 (diff) |
Allow specifying ALC_DONT_CARE_SOFT for ALC_HRTF_SOFT
ALC_FALSE now indicates explicitly no HRTF mixing, while ALC_DONT_CARE_SOFT
is autodetect.
-rw-r--r-- | Alc/ALc.c | 39 | ||||
-rw-r--r-- | OpenAL32/Include/alMain.h | 10 |
2 files changed, 31 insertions, 18 deletions
@@ -1806,10 +1806,13 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) if(attrList[attrIdx] == ALC_HRTF_SOFT) { - if(attrList[attrIdx + 1] != ALC_FALSE) - flags |= DEVICE_HRTF_REQUEST; + flags &= ~DEVICE_HRTF_REQUEST_MASK; + if(attrList[attrIdx + 1] == ALC_FALSE) + flags |= Hrtf_Disable; + else if(attrList[attrIdx + 1] == ALC_TRUE) + flags |= Hrtf_Enable; else - flags &= ~DEVICE_HRTF_REQUEST; + flags |= Hrtf_Default; } attrIdx += 2; @@ -1875,10 +1878,13 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) if(attrList[attrIdx] == ALC_HRTF_SOFT) { - if(attrList[attrIdx + 1] != ALC_FALSE) - device->Flags |= DEVICE_HRTF_REQUEST; + device->Flags &= ~DEVICE_HRTF_REQUEST_MASK; + if(attrList[attrIdx + 1] == ALC_FALSE) + device->Flags |= Hrtf_Disable; + else if(attrList[attrIdx + 1] == ALC_TRUE) + device->Flags |= Hrtf_Enable; else - device->Flags &= ~DEVICE_HRTF_REQUEST; + device->Flags |= Hrtf_Default; } attrIdx += 2; @@ -1913,18 +1919,17 @@ 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) || GetConfigValueBool(NULL, "hrtf", 0))) + if(device->Type != Loopback && ((device->Flags&DEVICE_HRTF_REQUEST_MASK) == Hrtf_Enable || GetConfigValueBool(NULL, "hrtf", 0))) { if(!FindHrtfFormat(&device->FmtChans, &device->Frequency)) { - device->Flags &= ~DEVICE_HRTF_REQUEST; + device->Flags &= ~DEVICE_HRTF_REQUEST_MASK; device->Hrtf_Status = ALC_HRTF_UNSUPPORTED_FORMAT_SOFT; } else - device->Flags |= DEVICE_CHANNELS_REQUEST | DEVICE_FREQUENCY_REQUEST | - DEVICE_HRTF_REQUEST; + device->Flags |= DEVICE_CHANNELS_REQUEST | DEVICE_FREQUENCY_REQUEST; } - if(device->Type == Loopback && (device->Flags&DEVICE_HRTF_REQUEST)) + if(device->Type == Loopback && (device->Flags&DEVICE_HRTF_REQUEST_MASK) == Hrtf_Enable) { enum DevFmtChannels chans = device->FmtChans; ALCuint freq = device->Frequency; @@ -1932,7 +1937,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) { ERR("Requested format not HRTF compatible: %s, %uhz\n", DevFmtChannelsString(device->FmtChans), device->Frequency); - device->Flags &= ~DEVICE_HRTF_REQUEST; + device->Flags &= ~DEVICE_HRTF_REQUEST_MASK; device->Hrtf_Status = ALC_HRTF_UNSUPPORTED_FORMAT_SOFT; } } @@ -2024,14 +2029,16 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) if(device->Type == Loopback || !ConfigValueBool(NULL, "hrtf", &usehrtf)) { - usehrtf = (headphones || (device->Flags&DEVICE_HRTF_REQUEST)); - if(headphones) + usehrtf = (headphones && (device->Flags&DEVICE_HRTF_REQUEST_MASK) != Hrtf_Disable) || + ((device->Flags&DEVICE_HRTF_REQUEST_MASK) == Hrtf_Enable); + if(headphones && (device->Flags&DEVICE_HRTF_REQUEST_MASK) != Hrtf_Disable) hrtf_status = ALC_HRTF_HEADPHONES_DETECTED_SOFT; else if(usehrtf) hrtf_status = ALC_HRTF_ENABLED_SOFT; } else { + device->Flags &= ~DEVICE_HRTF_REQUEST_MASK; if(!usehrtf) hrtf_status = ALC_HRTF_DENIED_SOFT; else @@ -2055,10 +2062,10 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) } else { - device->Flags &= ~DEVICE_HRTF_REQUEST; TRACE("HRTF disabled\n"); - bs2blevel = (headphones ? 5 : 0); + bs2blevel = ((headphones && (device->Flags&DEVICE_HRTF_REQUEST_MASK) != Hrtf_Disable) || + ((device->Flags&DEVICE_HRTF_REQUEST_MASK) == Hrtf_Enable)) ? 5 : 0; if(device->Type != Loopback) ConfigValueInt(NULL, "cf_level", &bs2blevel); if(bs2blevel > 0 && bs2blevel <= 6) diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index cd584966..8dad968f 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -42,6 +42,7 @@ #ifndef ALC_SOFT_HRTF #define ALC_SOFT_HRTF 1 #define ALC_HRTF_SOFT 0x1992 +#define ALC_DONT_CARE_SOFT 0x0002 #define ALC_HRTF_STATUS_SOFT 0x1993 #define ALC_HRTF_DISABLED_SOFT 0x0000 #define ALC_HRTF_ENABLED_SOFT 0x0001 @@ -764,8 +765,13 @@ struct ALCdevice_struct #define DEVICE_CHANNELS_REQUEST (1<<2) // Sample type was requested by the config file #define DEVICE_SAMPLE_TYPE_REQUEST (1<<3) -// HRTF was requested by the app -#define DEVICE_HRTF_REQUEST (1<<4) +// Mask and flags to indicate HRTF mode requested +#define DEVICE_HRTF_REQUEST_MASK ((1<<4) | (1<<5)) +enum HrtfRequestMode { + Hrtf_Default = 0, + Hrtf_Enable = 1<<4, + Hrtf_Disable = 2<<4, +}; // Specifies if the DSP is paused at user request #define DEVICE_PAUSED (1<<30) |