summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/ALc.c13
-rw-r--r--Alc/ALu.c16
-rw-r--r--OpenAL32/Include/alMain.h2
-rw-r--r--OpenAL32/alSource.c75
-rw-r--r--OpenAL32/alState.c8
5 files changed, 48 insertions, 66 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 53295fa0..7eefd9d1 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -1924,7 +1924,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
for(pos = 0;pos < context->ActiveSourceCount;pos++)
{
- ALactivesource *src = context->ActiveSources[pos];
+ ALactivesource *src = &context->ActiveSources[pos];
ALsource *source = src->Source;
ALuint s = device->NumAuxSends;
@@ -1937,8 +1937,8 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
if(source)
{
- src->Update(src, source, context);
ATOMIC_STORE(&source->NeedsUpdate, AL_FALSE);
+ src->Update(src, source, context);
}
}
@@ -2141,10 +2141,8 @@ static ALvoid InitContext(ALCcontext *Context)
* Cleans up the context, and destroys any remaining objects the app failed to
* delete. Called once there's no more references on the context.
*/
-static ALCvoid FreeContext(ALCcontext *context)
+static void FreeContext(ALCcontext *context)
{
- ALsizei i;
-
TRACE("%p\n", context);
if(context->SourceMap.size > 0)
@@ -2161,11 +2159,6 @@ static ALCvoid FreeContext(ALCcontext *context)
}
ResetUIntMap(&context->EffectSlotMap);
- for(i = 0;i < context->MaxActiveSources;i++)
- {
- al_free(context->ActiveSources[i]);
- context->ActiveSources[i] = NULL;
- }
free(context->ActiveSources);
context->ActiveSources = NULL;
context->ActiveSourceCount = 0;
diff --git a/Alc/ALu.c b/Alc/ALu.c
index c4a03fec..ce1b1cbd 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -1140,7 +1140,7 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
{
ALuint SamplesToDo;
ALeffectslot **slot, **slot_end;
- ALactivesource **src, **src_end;
+ ALactivesource *src, *src_end;
ALCcontext *ctx;
FPUCtl oldMode;
ALuint i, c;
@@ -1175,21 +1175,21 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
src_end = src + ctx->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;
goto next;
}
if(!DeferUpdates && (ATOMIC_EXCHANGE(ALenum, &source->NeedsUpdate, AL_FALSE) ||
UpdateSources))
- (*src)->Update(*src, source, ctx);
+ src->Update(src, source, ctx);
if(source->state != AL_PAUSED)
- MixSource(*src, source, device, SamplesToDo);
+ MixSource(src, source, device, SamplesToDo);
next:
src++;
}
@@ -1295,14 +1295,14 @@ ALvoid aluHandleDisconnect(ALCdevice *device)
Context = ATOMIC_LOAD(&device->ContextList);
while(Context)
{
- ALactivesource **src, **src_end;
+ ALactivesource *src, *src_end;
src = Context->ActiveSources;
src_end = src + Context->ActiveSourceCount;
while(src != src_end)
{
- ALsource *source = (*src)->Source;
- (*src)->Source = NULL;
+ ALsource *source = src->Source;
+ src->Source = NULL;
if(source && source->state == AL_PLAYING)
{
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++;
}