diff options
author | Chris Robinson <[email protected]> | 2018-10-03 13:48:04 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-10-03 13:48:04 -0700 |
commit | f3f94e478b0b186bd0de07e734b1d5e1222e0dee (patch) | |
tree | 2eccee93b550a23ef509cee0c5b3691f0c8e9231 | |
parent | c39eeb963895a2eb05e17bc28c357f7d3f4ce815 (diff) |
Don't limit output for ALC_DONT_CARE_SOFT and float samples
-rw-r--r-- | Alc/ALc.c | 32 | ||||
-rw-r--r-- | OpenAL32/Include/alMain.h | 2 |
2 files changed, 27 insertions, 7 deletions
@@ -1666,7 +1666,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) { enum HrtfRequestMode hrtf_userreq = Hrtf_Default; enum HrtfRequestMode hrtf_appreq = Hrtf_Default; - ALCenum gainLimiter = device->Limiter ? ALC_TRUE : ALC_FALSE; + ALCenum gainLimiter = device->LimiterState; const ALsizei old_sends = device->NumAuxSends; ALsizei new_sends = device->NumAuxSends; enum DevFmtChannels oldChans; @@ -2156,12 +2156,32 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) TRACE("Dithering enabled (%g-bit, %g)\n", log2f(device->DitherDepth)+1.0f, device->DitherDepth); + device->LimiterState = gainLimiter; if(ConfigValueBool(alstr_get_cstr(device->DeviceName), NULL, "output-limiter", &val)) gainLimiter = val ? ALC_TRUE : ALC_FALSE; + /* Valid values for gainLimiter are ALC_DONT_CARE_SOFT, ALC_TRUE, and - * ALC_FALSE. We default to on, so ALC_DONT_CARE_SOFT is the same as - * ALC_TRUE. + * ALC_FALSE. For ALC_DONT_CARE_SOFT, use the limiter for integer-based + * output (where samples must be clamped), and don't for floating-point + * (which can take unclamped samples). */ + if(gainLimiter == ALC_DONT_CARE_SOFT) + { + switch(device->FmtType) + { + case DevFmtByte: + case DevFmtUByte: + case DevFmtShort: + case DevFmtUShort: + case DevFmtInt: + case DevFmtUInt: + gainLimiter = ALC_TRUE; + break; + case DevFmtFloat: + gainLimiter = ALC_FALSE; + break; + } + } if(gainLimiter != ALC_FALSE) { ALfloat thrshld = 1.0f; @@ -2353,6 +2373,7 @@ static void InitDevice(ALCdevice *device, enum DeviceType type) device->Flags = 0; device->Render_Mode = NormalRender; device->AvgSpeakerDist = 0.0f; + device->LimiterState = ALC_DONT_CARE_SOFT; ATOMIC_INIT(&device->ContextList, NULL); @@ -4027,6 +4048,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) device->IsHeadphones = AL_FALSE; device->AmbiLayout = AmbiLayout_Default; device->AmbiScale = AmbiNorm_Default; + device->LimiterState = ALC_TRUE; device->NumUpdates = 3; device->UpdateSize = 1024; @@ -4165,8 +4187,6 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) ERR("Unsupported ambi-format: %s\n", fmt); } - device->Limiter = CreateDeviceLimiter(device, 0.0f); - { ALCdevice *head = ATOMIC_LOAD_SEQ(&DeviceList); do { @@ -4494,8 +4514,6 @@ ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceN // Open the "backend" V(device->Backend,open)("Loopback"); - device->Limiter = CreateDeviceLimiter(device, 0.0f); - { ALCdevice *head = ATOMIC_LOAD_SEQ(&DeviceList); do { diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index dce51301..0fd77491 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -622,6 +622,8 @@ struct ALCdevice_struct { enum AmbiLayout AmbiLayout; enum AmbiNorm AmbiScale; + ALCenum LimiterState; + al_string DeviceName; ATOMIC(ALCenum) LastError; |