diff options
-rw-r--r-- | Alc/ALc.c | 18 | ||||
-rw-r--r-- | Alc/helpers.c | 9 | ||||
-rw-r--r-- | OpenAL32/Include/alMain.h | 3 | ||||
-rw-r--r-- | OpenAL32/alAuxEffectSlot.c | 2 | ||||
-rw-r--r-- | OpenAL32/alSource.c | 9 |
5 files changed, 20 insertions, 21 deletions
@@ -429,7 +429,7 @@ BOOL APIENTRY DllMain(HANDLE hModule,DWORD ul_reason_for_call,LPVOID lpReserved) switch(ul_reason_for_call) { case DLL_PROCESS_ATTACH: - InitUIntMap(&TlsDestructor); + InitUIntMap(&TlsDestructor, ~0); alc_init(); break; @@ -1322,8 +1322,8 @@ static ALvoid InitContext(ALCcontext *pContext) pContext->LastError = AL_NO_ERROR; pContext->UpdateSources = AL_FALSE; pContext->ActiveSourceCount = 0; - InitUIntMap(&pContext->SourceMap); - InitUIntMap(&pContext->EffectSlotMap); + InitUIntMap(&pContext->SourceMap, pContext->Device->MaxNoOfSources); + InitUIntMap(&pContext->EffectSlotMap, pContext->Device->AuxiliaryEffectSlotMax); //Set globals pContext->DistanceModel = AL_INVERSE_DISTANCE_CLAMPED; @@ -2446,9 +2446,9 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) device->ContextList = NULL; device->NumContexts = 0; - InitUIntMap(&device->BufferMap); - InitUIntMap(&device->EffectMap); - InitUIntMap(&device->FilterMap); + InitUIntMap(&device->BufferMap, ~0); + InitUIntMap(&device->EffectMap, ~0); + InitUIntMap(&device->FilterMap, ~0); //Set output format if(ConfigValueExists(NULL, "frequency")) @@ -2608,9 +2608,9 @@ ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(void) device->ContextList = NULL; device->NumContexts = 0; - InitUIntMap(&device->BufferMap); - InitUIntMap(&device->EffectMap); - InitUIntMap(&device->FilterMap); + InitUIntMap(&device->BufferMap, ~0); + InitUIntMap(&device->EffectMap, ~0); + InitUIntMap(&device->FilterMap, ~0); //Set output format device->Frequency = 44100; diff --git a/Alc/helpers.c b/Alc/helpers.c index 8aa13111..989602f7 100644 --- a/Alc/helpers.c +++ b/Alc/helpers.c @@ -308,11 +308,12 @@ void WriteUnlock(RWLock *lock) } -void InitUIntMap(UIntMap *map) +void InitUIntMap(UIntMap *map, ALsizei limit) { map->array = NULL; map->size = 0; map->maxsize = 0; + map->limit = limit; map->lock.read_count = 0; map->lock.write_count = 0; map->lock.read_lock = AL_FALSE; @@ -335,6 +336,12 @@ ALenum InsertUIntMapEntry(UIntMap *map, ALuint key, ALvoid *value) ALsizei pos = 0; WriteLock(&map->lock); + if(map->size == map->limit) + { + WriteUnlock(&map->lock); + return AL_OUT_OF_MEMORY; + } + if(map->size > 0) { ALsizei low = 0; diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index fe9d3331..c712a38b 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -334,11 +334,12 @@ typedef struct UIntMap { } *array; ALsizei size; ALsizei maxsize; + ALsizei limit; RWLock lock; } UIntMap; extern UIntMap TlsDestructor; -void InitUIntMap(UIntMap *map); +void InitUIntMap(UIntMap *map, ALsizei limit); void ResetUIntMap(UIntMap *map); ALenum InsertUIntMapEntry(UIntMap *map, ALuint key, ALvoid *value); void RemoveUIntMapKey(UIntMap *map, ALuint key); diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c index 27d92949..b2411ed3 100644 --- a/OpenAL32/alAuxEffectSlot.c +++ b/OpenAL32/alAuxEffectSlot.c @@ -50,8 +50,6 @@ AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslo Device = Context->Device; if(n < 0 || IsBadWritePtr((void*)effectslots, n * sizeof(ALuint))) alSetError(Context, AL_INVALID_VALUE); - else if((ALuint)n > Device->AuxiliaryEffectSlotMax - Context->EffectSlotMap.size) - alSetError(Context, AL_INVALID_VALUE); else { ALenum err; diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c index e45cbcd9..2fc28e53 100644 --- a/OpenAL32/alSource.c +++ b/OpenAL32/alSource.c @@ -86,14 +86,7 @@ AL_API ALvoid AL_APIENTRY alGenSources(ALsizei n,ALuint *sources) err = NewThunkEntry(&source->source); if(err == AL_NO_ERROR) - { - LockContext(Context); - if(Device->MaxNoOfSources == (ALuint)Context->SourceMap.size) - err = AL_INVALID_VALUE; - else - err = InsertUIntMapEntry(&Context->SourceMap, source->source, source); - UnlockContext(Context); - } + err = InsertUIntMapEntry(&Context->SourceMap, source->source, source); if(err != AL_NO_ERROR) { FreeThunkEntry(source->source); |