aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2017-04-14 22:56:54 -0700
committerChris Robinson <[email protected]>2017-04-14 23:50:49 -0700
commitd9bf4f7620c1e13846a53ee9df5c8c9eb2fcfe7d (patch)
treeb3ab3fb963b8fbc5dbcafe4c8a6ffbd9e72ec572 /Alc
parentafb59e7f98f40cde77c150414a8a5bd13f40781a (diff)
Allow increasing the maximum source limit
If the requested number of mono and stereo sources exceeds 256, the source limit will be expanded. Any config file setting overrides this. If the device is reset to have fewer sources than are currently allocated, excess sources will remain and be usable as normal, but no more can be generated until enough are delated to go back below the limit.
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALc.c74
1 files changed, 59 insertions, 15 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index cc9aa5c3..2d0d64f5 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -1834,13 +1834,18 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
return ALC_INVALID_VALUE;
}
+ if(attrList[attrIdx] == ALC_MONO_SOURCES)
+ {
+ numMono = attrList[attrIdx + 1];
+ TRACE_ATTR(ALC_MONO_SOURCES, numMono);
+ numMono = maxi(numMono, 0);
+ }
+
if(attrList[attrIdx] == ALC_STEREO_SOURCES)
{
numStereo = attrList[attrIdx + 1];
TRACE_ATTR(ALC_STEREO_SOURCES, numStereo);
-
- numStereo = clampi(numStereo, 0, device->SourcesMax);
- numMono = device->SourcesMax - numStereo;
+ numStereo = maxi(numStereo, 0);
}
if(attrList[attrIdx] == ALC_MAX_AUXILIARY_SENDS)
@@ -1898,6 +1903,21 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
device->AmbiLayout = alayout;
device->AmbiScale = ascale;
}
+
+ if(numMono > INT_MAX-numStereo)
+ numMono = INT_MAX-numStereo;
+ numMono += numStereo;
+ if(ConfigValueInt(NULL, NULL, "sources", &numMono))
+ {
+ if(numMono <= 0)
+ numMono = 256;
+ }
+ else
+ numMono = maxi(numMono, 256);
+ numStereo = mini(numStereo, numMono);
+ numMono -= numStereo;
+ device->SourcesMax = numMono + numStereo;
+
device->NumMonoSources = numMono;
device->NumStereoSources = numStereo;
@@ -1935,13 +1955,18 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
device->Flags |= DEVICE_FREQUENCY_REQUEST;
}
+ if(attrList[attrIdx] == ALC_MONO_SOURCES)
+ {
+ numMono = attrList[attrIdx + 1];
+ TRACE_ATTR(ALC_MONO_SOURCES, numMono);
+ numMono = maxi(numMono, 0);
+ }
+
if(attrList[attrIdx] == ALC_STEREO_SOURCES)
{
numStereo = attrList[attrIdx + 1];
TRACE_ATTR(ALC_STEREO_SOURCES, numStereo);
-
- numStereo = clampi(numStereo, 0, device->SourcesMax);
- numMono = device->SourcesMax - numStereo;
+ numStereo = maxi(numStereo, 0);
}
if(attrList[attrIdx] == ALC_MAX_AUXILIARY_SENDS)
@@ -1982,6 +2007,21 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
device->UpdateSize = (device->UpdateSize+3)&~3;
device->Frequency = freq;
+
+ if(numMono > INT_MAX-numStereo)
+ numMono = INT_MAX-numStereo;
+ numMono += numStereo;
+ if(ConfigValueInt(alstr_get_cstr(device->DeviceName), NULL, "sources", &numMono))
+ {
+ if(numMono <= 0)
+ numMono = 256;
+ }
+ else
+ numMono = maxi(numMono, 256);
+ numStereo = mini(numStereo, numMono);
+ numMono -= numStereo;
+ device->SourcesMax = numMono + numStereo;
+
device->NumMonoSources = numMono;
device->NumStereoSources = numStereo;
@@ -2150,6 +2190,9 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
* allocated with the appropriate size.
*/
device->NumAuxSends = new_sends;
+ TRACE("Max sources: %d (%d + %d), effect slots: %d, sends: %d\n",
+ device->SourcesMax, device->NumMonoSources, device->NumStereoSources,
+ device->AuxiliaryEffectSlotMax, device->NumAuxSends);
update_failed = AL_FALSE;
SetMixerFPUMode(&oldMode);
if(device->DefaultSlot)
@@ -2187,6 +2230,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
UnlockUIntMapRead(&context->EffectSlotMap);
LockUIntMapRead(&context->SourceMap);
+ RelimitUIntMapNoLock(&context->SourceMap, device->SourcesMax);
for(pos = 0;pos < context->SourceMap.size;pos++)
{
ALsource *source = context->SourceMap.values[pos];
@@ -3751,9 +3795,9 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName)
device->AuxiliaryEffectSlotMax = 64;
device->NumAuxSends = DEFAULT_SENDS;
- InitUIntMap(&device->BufferMap, ~0);
- InitUIntMap(&device->EffectMap, ~0);
- InitUIntMap(&device->FilterMap, ~0);
+ InitUIntMap(&device->BufferMap, INT_MAX);
+ InitUIntMap(&device->EffectMap, INT_MAX);
+ InitUIntMap(&device->FilterMap, INT_MAX);
for(i = 0;i < MAX_OUTPUT_CHANNELS;i++)
{
@@ -4051,9 +4095,9 @@ ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *deviceName,
device->RealOut.Buffer = NULL;
device->RealOut.NumChannels = 0;
- InitUIntMap(&device->BufferMap, ~0);
- InitUIntMap(&device->EffectMap, ~0);
- InitUIntMap(&device->FilterMap, ~0);
+ InitUIntMap(&device->BufferMap, INT_MAX);
+ InitUIntMap(&device->EffectMap, INT_MAX);
+ InitUIntMap(&device->FilterMap, INT_MAX);
for(i = 0;i < MAX_OUTPUT_CHANNELS;i++)
{
@@ -4279,9 +4323,9 @@ ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceN
device->AuxiliaryEffectSlotMax = 64;
device->NumAuxSends = DEFAULT_SENDS;
- InitUIntMap(&device->BufferMap, ~0);
- InitUIntMap(&device->EffectMap, ~0);
- InitUIntMap(&device->FilterMap, ~0);
+ InitUIntMap(&device->BufferMap, INT_MAX);
+ InitUIntMap(&device->EffectMap, INT_MAX);
+ InitUIntMap(&device->FilterMap, INT_MAX);
for(i = 0;i < MAX_OUTPUT_CHANNELS;i++)
{