aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/ALu.c
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 /Alc/ALu.c
parent0760415d08031eea36abf193537c8c8a120cb2e6 (diff)
Use a map to store sources and buffers
And do a lookup using a binary search instead of linear
Diffstat (limited to 'Alc/ALu.c')
-rw-r--r--Alc/ALu.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 8d5d85c1..db5a9eb7 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -943,8 +943,9 @@ static void MixSomeSources(ALCcontext *ALContext, float (*DryBuffer)[OUTPUTCHANN
ALuint BuffersPlayed;
ALfloat Pitch;
ALenum State;
+ ALsizei pos;
- if(!(ALSource=ALContext->SourceList))
+ if(ALContext->SourceMap.size <= 0)
return;
DuplicateStereo = ALContext->Device->DuplicateStereo;
@@ -953,13 +954,13 @@ static void MixSomeSources(ALCcontext *ALContext, float (*DryBuffer)[OUTPUTCHANN
rampLength = DeviceFreq * MIN_RAMP_LENGTH / 1000;
rampLength = max(rampLength, SamplesToDo);
-another_source:
- if(ALSource->state != AL_PLAYING)
- {
- if((ALSource=ALSource->next) != NULL)
- goto another_source;
- return;
- }
+ pos = ALContext->SourceMap.size;
+next_source:
+ do {
+ if(pos-- <= 0)
+ return;
+ ALSource = ALContext->SourceMap.array[pos].value;
+ } while(ALSource->state != AL_PLAYING);
j = 0;
/* Find buffer format */
@@ -1399,8 +1400,7 @@ another_source:
ALSource->FirstStart = AL_FALSE;
- if((ALSource=ALSource->next) != NULL)
- goto another_source;
+ goto next_source;
}
ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
@@ -1611,13 +1611,15 @@ ALvoid aluHandleDisconnect(ALCdevice *device)
SuspendContext(NULL);
for(i = 0;i < device->NumContexts;i++)
{
+ ALCcontext *Context = device->Contexts[i];
ALsource *source;
+ ALsizei pos;
- SuspendContext(device->Contexts[i]);
+ SuspendContext(Context);
- source = device->Contexts[i]->SourceList;
- while(source)
+ for(pos = 0;pos < Context->SourceMap.size;pos++)
{
+ source = Context->SourceMap.array[pos].value;
if(source->state == AL_PLAYING)
{
source->state = AL_STOPPED;
@@ -1625,9 +1627,8 @@ ALvoid aluHandleDisconnect(ALCdevice *device)
source->position = 0;
source->position_fraction = 0;
}
- source = source->next;
}
- ProcessContext(device->Contexts[i]);
+ ProcessContext(Context);
}
device->Connected = ALC_FALSE;