aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/ALc.c17
-rw-r--r--Alc/ALu.c2
-rw-r--r--OpenAL32/Include/alMain.h2
-rw-r--r--OpenAL32/alState.c10
-rw-r--r--alsoftrc.sample7
5 files changed, 32 insertions, 6 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 {
diff --git a/Alc/ALu.c b/Alc/ALu.c
index f93781df..13aff5d9 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -278,7 +278,7 @@ static ALboolean CalcListenerParams(ALCcontext *Context)
0.0f);
Listener->Params.Velocity = aluMatrixfVector(&Listener->Params.Matrix, &vel);
- Listener->Params.Gain = ATOMIC_LOAD(&props->Gain, almemory_order_relaxed);
+ Listener->Params.Gain = ATOMIC_LOAD(&props->Gain, almemory_order_relaxed) * Context->GainBoost;
Listener->Params.MetersPerUnit = ATOMIC_LOAD(&props->MetersPerUnit, almemory_order_relaxed);
Listener->Params.DopplerFactor = ATOMIC_LOAD(&props->DopplerFactor, almemory_order_relaxed);
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 356a749a..6320bc98 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -749,6 +749,8 @@ struct ALCcontext_struct {
RefCount UpdateCount;
ATOMIC(ALenum) HoldUpdates;
+ ALfloat GainBoost;
+
struct ALvoice *Voices;
ALsizei VoiceCount;
ALsizei MaxVoices;
diff --git a/OpenAL32/alState.c b/OpenAL32/alState.c
index c25aa63e..3d8e6c40 100644
--- a/OpenAL32/alState.c
+++ b/OpenAL32/alState.c
@@ -155,7 +155,7 @@ AL_API ALboolean AL_APIENTRY alGetBoolean(ALenum pname)
break;
case AL_GAIN_LIMIT_SOFT:
- if(GAIN_MIX_MAX != 0.0f)
+ if(GAIN_MIX_MAX/context->GainBoost != 0.0f)
value = AL_TRUE;
break;
@@ -201,7 +201,7 @@ AL_API ALdouble AL_APIENTRY alGetDouble(ALenum pname)
break;
case AL_GAIN_LIMIT_SOFT:
- value = (ALdouble)GAIN_MIX_MAX;
+ value = (ALdouble)GAIN_MIX_MAX/context->GainBoost;
break;
default:
@@ -246,7 +246,7 @@ AL_API ALfloat AL_APIENTRY alGetFloat(ALenum pname)
break;
case AL_GAIN_LIMIT_SOFT:
- value = GAIN_MIX_MAX;
+ value = GAIN_MIX_MAX/context->GainBoost;
break;
default:
@@ -291,7 +291,7 @@ AL_API ALint AL_APIENTRY alGetInteger(ALenum pname)
break;
case AL_GAIN_LIMIT_SOFT:
- value = (ALint)GAIN_MIX_MAX;
+ value = (ALint)(GAIN_MIX_MAX/context->GainBoost);
break;
default:
@@ -336,7 +336,7 @@ AL_API ALint64SOFT AL_APIENTRY alGetInteger64SOFT(ALenum pname)
break;
case AL_GAIN_LIMIT_SOFT:
- value = (ALint64SOFT)GAIN_MIX_MAX;
+ value = (ALint64SOFT)(GAIN_MIX_MAX/context->GainBoost);
break;
default:
diff --git a/alsoftrc.sample b/alsoftrc.sample
index 444ebc6f..d5913ff0 100644
--- a/alsoftrc.sample
+++ b/alsoftrc.sample
@@ -182,6 +182,13 @@
# possible is 4.
#sends =
+## volume-adjust:
+# A global volume adjustment for source output, expressed in decibels. The
+# value is logarithmic, so +6 will be a scale of (approximately) 2x, +12 will
+# be a scale of 4x, etc. Similarly, -6 will be x1/2, and -12 is about x1/4. A
+# value of 0 means no change.
+#volume-adjust = 0
+
## excludefx: (global)
# Sets which effects to exclude, preventing apps from using them. This can
# help for apps that try to use effects which are too CPU intensive for the