aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2017-03-05 04:50:27 -0800
committerChris Robinson <[email protected]>2017-03-05 04:50:27 -0800
commit073829f26a4a509d11de5375d43169a8f6ba9e12 (patch)
tree28a341bd1a5954ff9e94a3332bc843314c52f2d0 /Alc
parentc0404916150c48769d08ac32921b9a6a66dc0c0a (diff)
Make the voice's source pointer atomic
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALc.c2
-rw-r--r--Alc/ALu.c12
2 files changed, 7 insertions, 7 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 59475e48..42e1cea0 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -1721,7 +1721,7 @@ void ALCcontext_ProcessUpdates(ALCcontext *context)
for(pos = 0;pos < context->VoiceCount;pos++)
{
ALvoice *voice = context->Voices[pos];
- ALsource *source = voice->Source;
+ ALsource *source = ATOMIC_LOAD(&voice->Source, almemory_order_acquire);
if(source && source->OffsetType != AL_NONE)
{
WriteLock(&source->queue_lock);
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 0a1b919a..e14c2013 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -1277,8 +1277,8 @@ static void UpdateContextSources(ALCcontext *ctx, ALeffectslot *slot)
voice_end = voice + ctx->VoiceCount;
for(;voice != voice_end;++voice)
{
- if((source=(*voice)->Source) != NULL)
- CalcSourceParams(*voice, source, ctx, force);
+ source = ATOMIC_LOAD(&(*voice)->Source, almemory_order_acquire);
+ if(source) CalcSourceParams(*voice, source, ctx, force);
}
}
IncrementRef(&ctx->UpdateCount);
@@ -1419,13 +1419,13 @@ void aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
voice_end = voice + ctx->VoiceCount;
for(;voice != voice_end;++voice)
{
- source = (*voice)->Source;
+ source = ATOMIC_LOAD(&(*voice)->Source, almemory_order_acquire);
if(source && ATOMIC_LOAD(&(*voice)->Playing, almemory_order_relaxed) &&
(*voice)->Step > 0)
{
if(!MixSource(*voice, source, device, SamplesToDo))
{
- (*voice)->Source = NULL;
+ ATOMIC_STORE(&(*voice)->Source, NULL, almemory_order_relaxed);
ATOMIC_STORE(&(*voice)->Playing, false, almemory_order_release);
}
}
@@ -1592,8 +1592,8 @@ void aluHandleDisconnect(ALCdevice *device)
voice_end = voice + Context->VoiceCount;
while(voice != voice_end)
{
- ALsource *source = (*voice)->Source;
- (*voice)->Source = NULL;
+ ALsource *source = ATOMIC_EXCHANGE(ALsource*, &(*voice)->Source, NULL,
+ almemory_order_acq_rel);
ATOMIC_STORE(&(*voice)->Playing, false, almemory_order_release);
if(source)