aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/Include/alMain.h2
-rw-r--r--OpenAL32/alSource.c75
-rw-r--r--OpenAL32/alState.c8
3 files changed, 37 insertions, 48 deletions
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 111dde95..0aea19e2 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -748,7 +748,7 @@ struct ALCcontext_struct
volatile ALfloat SpeedOfSound;
volatile ALenum DeferUpdates;
- struct ALactivesource **ActiveSources;
+ struct ALactivesource *ActiveSources;
ALsizei ActiveSourceCount;
ALsizei MaxActiveSources;
diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c
index 44969cbf..09d61fc7 100644
--- a/OpenAL32/alSource.c
+++ b/OpenAL32/alSource.c
@@ -1389,7 +1389,7 @@ AL_API ALvoid AL_APIENTRY alDeleteSources(ALsizei n, const ALuint *sources)
}
for(i = 0;i < n;i++)
{
- ALactivesource **srclist, **srclistend;
+ ALactivesource *srclist, *srclistend;
if((Source=RemoveSource(context, sources[i])) == NULL)
continue;
@@ -1401,7 +1401,7 @@ AL_API ALvoid AL_APIENTRY alDeleteSources(ALsizei n, const ALuint *sources)
while(srclist != srclistend)
{
ALsource *old = Source;
- if(COMPARE_EXCHANGE(&(*srclist)->Source, &old, NULL))
+ if(COMPARE_EXCHANGE(&srclist->Source, &old, NULL))
break;
srclist++;
}
@@ -2017,7 +2017,7 @@ AL_API ALvoid AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources)
LockContext(context);
while(n > context->MaxActiveSources-context->ActiveSourceCount)
{
- ALactivesource **temp = NULL;
+ ALactivesource *temp = NULL;
ALsizei newcount;
newcount = context->MaxActiveSources << 1;
@@ -2029,8 +2029,7 @@ AL_API ALvoid AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources)
UnlockContext(context);
SET_ERROR_AND_GOTO(context, AL_OUT_OF_MEMORY, done);
}
- for(i = context->MaxActiveSources;i < newcount;i++)
- temp[i] = NULL;
+ memset(&temp[context->MaxActiveSources], 0, (newcount-context->MaxActiveSources) * sizeof(temp[0]));
context->ActiveSources = temp;
context->MaxActiveSources = newcount;
@@ -2483,58 +2482,48 @@ ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state)
if(!BufferList || !device->Connected)
goto do_stop;
+ /* Make sure this source isn't already active, while looking for an
+ * unused active source slot to put it in. */
for(i = 0;i < Context->ActiveSourceCount;i++)
{
- if(Context->ActiveSources[i]->Source == Source)
+ ALsource *old = Source;
+ if(COMPARE_EXCHANGE(&Context->ActiveSources[i].Source, &old, NULL))
{
- src = Context->ActiveSources[i];
+ if(src == NULL)
+ {
+ src = &Context->ActiveSources[i];
+ src->Source = Source;
+ }
break;
}
+ old = NULL;
+ if(src == NULL && COMPARE_EXCHANGE(&Context->ActiveSources[i].Source, &old, Source))
+ src = &Context->ActiveSources[i];
}
if(src == NULL)
{
- for(i = 0;i < Context->ActiveSourceCount;i++)
- {
- ALsource *old = NULL;
- src = Context->ActiveSources[i];
- if(COMPARE_EXCHANGE(&src->Source, &old, Source))
- break;
- }
- if(i == Context->ActiveSourceCount)
- {
- src = Context->ActiveSources[Context->ActiveSourceCount];
- if(src == NULL)
- {
- src = al_malloc(16, sizeof(src[0]));
- Context->ActiveSources[Context->ActiveSourceCount] = src;
- }
- Context->ActiveSourceCount++;
- }
- memset(src, 0, sizeof(*src));
-
+ src = &Context->ActiveSources[Context->ActiveSourceCount++];
src->Source = Source;
}
- else
+
+ src->Direct.Moving = AL_FALSE;
+ src->Direct.Counter = 0;
+ for(i = 0;i < MAX_INPUT_CHANNELS;i++)
{
- src->Direct.Moving = AL_FALSE;
- src->Direct.Counter = 0;
- for(i = 0;i < MAX_INPUT_CHANNELS;i++)
- {
- ALsizei j;
- for(j = 0;j < SRC_HISTORY_LENGTH;j++)
- src->Direct.Mix.Hrtf.State[i].History[j] = 0.0f;
- for(j = 0;j < HRIR_LENGTH;j++)
- {
- src->Direct.Mix.Hrtf.State[i].Values[j][0] = 0.0f;
- src->Direct.Mix.Hrtf.State[i].Values[j][1] = 0.0f;
- }
- }
- for(i = 0;i < (ALsizei)device->NumAuxSends;i++)
+ ALsizei j;
+ for(j = 0;j < SRC_HISTORY_LENGTH;j++)
+ src->Direct.Mix.Hrtf.State[i].History[j] = 0.0f;
+ for(j = 0;j < HRIR_LENGTH;j++)
{
- src->Send[i].Counter = 0;
- src->Send[i].Moving = AL_FALSE;
+ src->Direct.Mix.Hrtf.State[i].Values[j][0] = 0.0f;
+ src->Direct.Mix.Hrtf.State[i].Values[j][1] = 0.0f;
}
}
+ for(i = 0;i < (ALsizei)device->NumAuxSends;i++)
+ {
+ src->Send[i].Counter = 0;
+ src->Send[i].Moving = AL_FALSE;
+ }
if(BufferList->buffer->FmtChannels == FmtMono)
src->Update = CalcSourceParams;
diff --git a/OpenAL32/alState.c b/OpenAL32/alState.c
index 699bea20..77eefc8b 100644
--- a/OpenAL32/alState.c
+++ b/OpenAL32/alState.c
@@ -715,7 +715,7 @@ AL_API ALvoid AL_APIENTRY alDeferUpdatesSOFT(void)
if(!context->DeferUpdates)
{
ALboolean UpdateSources;
- ALactivesource **src, **src_end;
+ ALactivesource *src, *src_end;
ALeffectslot **slot, **slot_end;
FPUCtl oldMode;
@@ -731,17 +731,17 @@ AL_API ALvoid AL_APIENTRY alDeferUpdatesSOFT(void)
src_end = src + context->ActiveSourceCount;
while(src != src_end)
{
- ALsource *source = (*src)->Source;
+ ALsource *source = src->Source;
if(!source) goto next;
if(source->state != AL_PLAYING && source->state != AL_PAUSED)
{
- (*src)->Source = NULL;
+ src->Source = NULL;
continue;
}
if(ATOMIC_EXCHANGE(ALenum, &source->NeedsUpdate, AL_FALSE) || UpdateSources)
- (*src)->Update(*src, source, context);
+ src->Update(src, source, context);
next:
src++;
}