diff options
author | Chris Robinson <[email protected]> | 2017-04-14 22:56:54 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2017-04-14 23:50:49 -0700 |
commit | d9bf4f7620c1e13846a53ee9df5c8c9eb2fcfe7d (patch) | |
tree | b3ab3fb963b8fbc5dbcafe4c8a6ffbd9e72ec572 /common | |
parent | afb59e7f98f40cde77c150414a8a5bd13f40781a (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 'common')
-rw-r--r-- | common/uintmap.c | 9 | ||||
-rw-r--r-- | common/uintmap.h | 3 |
2 files changed, 9 insertions, 3 deletions
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); |