aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/ALc.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2016-09-24 18:46:41 -0700
committerChris Robinson <[email protected]>2016-09-24 18:46:41 -0700
commitf5e4a3ed85993f479c6cc1a967d5252378eb5211 (patch)
treeac45d22c3f4ea5e4df0ffef5720b09ee840c1ac4 /Alc/ALc.c
parent24f9a0f2aed5b0770af1633ab4a2e2832462294e (diff)
Add a volume-adjust config option to adjust the source output volume
Designed for apps that either don't change the listener's AL_GAIN, or don't allow the listener's AL_GAIN to go above 1. This allows the volume to still be increased further than such apps may allow, if users find it too quiet. Be aware that increasing this can easily cause clipping. The gain limit reported by AL_GAIN_LIMIT_SOFT is also affected by this.
Diffstat (limited to 'Alc/ALc.c')
-rw-r--r--Alc/ALc.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index c4eb0462..a37e1242 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -2319,6 +2319,7 @@ static ALvoid InitContext(ALCcontext *Context)
//Validate Context
InitRef(&Context->UpdateCount, 0);
ATOMIC_INIT(&Context->HoldUpdates, AL_FALSE);
+ Context->GainBoost = 1.0f;
RWLockInit(&Context->PropLock);
ATOMIC_INIT(&Context->LastError, AL_NO_ERROR);
InitUIntMap(&Context->SourceMap, Context->Device->SourcesMax);
@@ -3159,6 +3160,7 @@ ALC_API ALCenum ALC_APIENTRY alcGetEnumValue(ALCdevice *device, const ALCchar *e
ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCint *attrList)
{
ALCcontext *ALContext;
+ ALfloat valf;
ALCenum err;
LockLists();
@@ -3229,6 +3231,21 @@ ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCin
ALCdevice_IncRef(device);
InitContext(ALContext);
+ if(ConfigValueFloat(al_string_get_cstr(device->DeviceName), NULL, "volume-adjust", &valf))
+ {
+ if(!isfinite(valf))
+ ERR("volume-adjust must be finite: %f\n", valf);
+ else
+ {
+ ALfloat db = clampf(valf, -24.0f, 24.0f);
+ if(db != valf)
+ WARN("volume-adjust clamped: %f, range: +/-%f\n", valf, 24.0f);
+ ALContext->GainBoost = powf(10.0f, db/20.0f);
+ TRACE("volume-adjust gain: %f\n", ALContext->GainBoost);
+ }
+ }
+ UpdateListenerProps(ALContext);
+
{
ALCcontext *head = ATOMIC_LOAD(&device->ContextList);
do {