aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/ALc.c74
-rw-r--r--OpenAL32/alAuxEffectSlot.c2
-rw-r--r--common/uintmap.c9
-rw-r--r--common/uintmap.h3
4 files changed, 69 insertions, 19 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++)
{
diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c
index de7de943..3ec857ca 100644
--- a/OpenAL32/alAuxEffectSlot.c
+++ b/OpenAL32/alAuxEffectSlot.c
@@ -479,7 +479,7 @@ done:
void InitEffectFactoryMap(void)
{
- InitUIntMap(&EffectStateFactoryMap, ~0);
+ InitUIntMap(&EffectStateFactoryMap, INT_MAX);
InsertUIntMapEntry(&EffectStateFactoryMap, AL_EFFECT_NULL, ALnullStateFactory_getFactory);
InsertUIntMapEntry(&EffectStateFactoryMap, AL_EFFECT_EAXREVERB, ALreverbStateFactory_getFactory);
diff --git a/common/uintmap.c b/common/uintmap.c
index 21a921b2..98ed3191 100644
--- a/common/uintmap.c
+++ b/common/uintmap.c
@@ -36,6 +36,11 @@ void ResetUIntMap(UIntMap *map)
WriteUnlock(&map->lock);
}
+void RelimitUIntMapNoLock(UIntMap *map, ALsizei limit)
+{
+ map->limit = limit;
+}
+
ALenum InsertUIntMapEntry(UIntMap *map, ALuint key, ALvoid *value)
{
ALsizei pos = 0;
@@ -59,7 +64,7 @@ ALenum InsertUIntMapEntry(UIntMap *map, ALuint key, ALvoid *value)
if(pos == map->size || map->keys[pos] != key)
{
- if(map->size == map->limit)
+ if(map->size >= map->limit)
{
WriteUnlock(&map->lock);
return AL_OUT_OF_MEMORY;
@@ -141,7 +146,7 @@ ALenum InsertUIntMapEntryNoLock(UIntMap *map, ALuint key, ALvoid *value)
if(pos == map->size || map->keys[pos] != key)
{
- if(map->size == map->limit)
+ if(map->size >= map->limit)
return AL_OUT_OF_MEMORY;
if(map->size == map->capacity)
diff --git a/common/uintmap.h b/common/uintmap.h
index f70d99fd..47bd0d42 100644
--- a/common/uintmap.h
+++ b/common/uintmap.h
@@ -19,10 +19,11 @@ typedef struct UIntMap {
RWLock lock;
} UIntMap;
#define UINTMAP_STATIC_INITIALIZE_N(_n) { NULL, NULL, 0, 0, (_n), RWLOCK_STATIC_INITIALIZE }
-#define UINTMAP_STATIC_INITIALIZE UINTMAP_STATIC_INITIALIZE_N(~0)
+#define UINTMAP_STATIC_INITIALIZE UINTMAP_STATIC_INITIALIZE_N(INT_MAX)
void InitUIntMap(UIntMap *map, ALsizei limit);
void ResetUIntMap(UIntMap *map);
+void RelimitUIntMapNoLock(UIntMap *map, ALsizei limit);
ALenum InsertUIntMapEntry(UIntMap *map, ALuint key, ALvoid *value);
ALenum InsertUIntMapEntryNoLock(UIntMap *map, ALuint key, ALvoid *value);
ALvoid *RemoveUIntMapKey(UIntMap *map, ALuint key);