aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32/Include
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2010-05-01 19:59:41 -0700
committerChris Robinson <[email protected]>2010-05-01 19:59:41 -0700
commit0378422fcb4badba0a0dcdce503dcbe9d253f9a8 (patch)
treeb7bf68507f0b8fa7716c821db445c88df060af29 /OpenAL32/Include
parent0760415d08031eea36abf193537c8c8a120cb2e6 (diff)
Use a map to store sources and buffers
And do a lookup using a binary search instead of linear
Diffstat (limited to 'OpenAL32/Include')
-rw-r--r--OpenAL32/Include/alBuffer.h2
-rw-r--r--OpenAL32/Include/alMain.h43
-rw-r--r--OpenAL32/Include/alSource.h2
3 files changed, 38 insertions, 9 deletions
diff --git a/OpenAL32/Include/alBuffer.h b/OpenAL32/Include/alBuffer.h
index 9035ccd6..9561b057 100644
--- a/OpenAL32/Include/alBuffer.h
+++ b/OpenAL32/Include/alBuffer.h
@@ -22,8 +22,6 @@ typedef struct ALbuffer
// Index to itself
ALuint buffer;
-
- struct ALbuffer *next;
} ALbuffer;
ALvoid ReleaseALBuffers(ALCdevice *device);
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 27c1f981..5f40bcc7 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -226,6 +226,41 @@ void alc_pulse_deinit(void);
void alc_pulse_probe(int type);
+typedef struct UIntMap {
+ struct {
+ ALuint key;
+ ALvoid *value;
+ } *array;
+ ALsizei size;
+ ALsizei maxsize;
+} UIntMap;
+
+void InitUIntMap(UIntMap *map);
+void ResetUIntMap(UIntMap *map);
+ALenum InsertUIntMapEntry(UIntMap *map, ALuint key, ALvoid *value);
+void RemoveUIntMapKey(UIntMap *map, ALuint key);
+
+static inline ALvoid *LookupUIntMapKey(UIntMap *map, ALuint key)
+{
+ if(map->size > 0)
+ {
+ ALsizei low = 0;
+ ALsizei high = map->size - 1;
+ while(low < high)
+ {
+ ALsizei mid = low + (high-low)/2;
+ if(map->array[mid].key < key)
+ low = mid + 1;
+ else
+ high = mid;
+ }
+ if(map->array[low].key == key)
+ return map->array[low].value;
+ }
+ return NULL;
+}
+
+
struct ALCdevice_struct
{
ALCboolean Connected;
@@ -249,9 +284,8 @@ struct ALCdevice_struct
ALCuint NumStereoSources;
ALuint NumAuxSends;
- // Linked List of Buffers for this device
- struct ALbuffer *BufferList;
- ALuint BufferCount;
+ // Map of Buffers for this device
+ UIntMap BufferMap;
// Linked List of Effects for this device
struct ALeffect *EffectList;
@@ -311,8 +345,7 @@ struct ALCcontext_struct
{
ALlistener Listener;
- struct ALsource *SourceList;
- ALuint SourceCount;
+ UIntMap SourceMap;
struct ALeffectslot *EffectSlotList;
ALuint EffectSlotCount;
diff --git a/OpenAL32/Include/alSource.h b/OpenAL32/Include/alSource.h
index d82ac1c0..0802cbaa 100644
--- a/OpenAL32/Include/alSource.h
+++ b/OpenAL32/Include/alSource.h
@@ -104,8 +104,6 @@ typedef struct ALsource
// Index to itself
ALuint source;
-
- struct ALsource *next;
} ALsource;
ALvoid ReleaseALSources(ALCcontext *Context);