aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/ALc.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2017-06-17 23:09:51 -0700
committerChris Robinson <[email protected]>2017-06-17 23:09:51 -0700
commit2b013fc54e8cf9be2184e20a6cd17c4696401ca9 (patch)
tree3889fa5bd352b53848b68608ebc68c706a392446 /Alc/ALc.c
parente3a825b37c5f43593467f2df3cd225904a259cf8 (diff)
Make the dithering depth configurable
Diffstat (limited to 'Alc/ALc.c')
-rw-r--r--Alc/ALc.c35
1 files changed, 29 insertions, 6 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index b31c4f08..7f6cf279 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -2222,6 +2222,35 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
device->SourcesMax, device->NumMonoSources, device->NumStereoSources,
device->AuxiliaryEffectSlotMax, device->NumAuxSends);
+ if(!GetConfigValueBool(alstr_get_cstr(device->DeviceName), NULL, "dither", 1))
+ device->DitherDepth = 0.0f;
+ else
+ {
+ ALint depth = 0;
+ ConfigValueInt(alstr_get_cstr(device->DeviceName), NULL, "dither-depth", &depth);
+ if(depth <= 0)
+ {
+ switch(device->FmtType)
+ {
+ case DevFmtByte:
+ case DevFmtUByte:
+ depth = 8;
+ break;
+ case DevFmtShort:
+ case DevFmtUShort:
+ depth = 16;
+ break;
+ case DevFmtInt:
+ case DevFmtUInt:
+ case DevFmtFloat:
+ break;
+ }
+ }
+ else if(depth > 24)
+ depth = 24;
+ device->DitherDepth = (depth > 0) ? powf(2.0f, (ALfloat)(depth-1)) : 0.0f;
+ }
+
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
@@ -4026,10 +4055,6 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName)
ERR("Unsupported ambi-format: %s\n", fmt);
}
- device->DitherEnabled = GetConfigValueBool(
- alstr_get_cstr(device->DeviceName), NULL, "dither", 1
- );
-
device->Limiter = CreateDeviceLimiter(device);
if(DefaultEffect.type != AL_EFFECT_NULL)
@@ -4450,8 +4475,6 @@ ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceN
// Open the "backend"
V(device->Backend,open)("Loopback");
- device->DitherEnabled = GetConfigValueBool(NULL, NULL, "dither", 1);
-
device->Limiter = CreateDeviceLimiter(device);
{