aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/ALu.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2017-03-02 00:49:03 -0800
committerChris Robinson <[email protected]>2017-03-02 01:02:40 -0800
commit6d7a790183552aa783d6043c755a10693d2f9369 (patch)
treea6012f98349ea598f365f3c92337ef841bdb3942 /Alc/ALu.c
parent0e8ca50d7ad6b30793772a4451b974e2d28895cf (diff)
Add a boolean to specify if a voice should be playing
Diffstat (limited to 'Alc/ALu.c')
-rw-r--r--Alc/ALu.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 9fe5712d..0a1b919a 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -1224,9 +1224,8 @@ static void CalcAttnSourceParams(ALvoice *voice, const struct ALsourceProps *pro
}
}
-static void CalcSourceParams(ALvoice *voice, ALCcontext *context, ALboolean force)
+static void CalcSourceParams(ALvoice *voice, ALsource *source, ALCcontext *context, ALboolean force)
{
- ALsource *source = voice->Source;
const ALbufferlistitem *BufferListItem;
struct ALsourceProps *props;
@@ -1278,11 +1277,8 @@ static void UpdateContextSources(ALCcontext *ctx, ALeffectslot *slot)
voice_end = voice + ctx->VoiceCount;
for(;voice != voice_end;++voice)
{
- if(!(source=(*voice)->Source)) continue;
- if(!IsPlayingOrPaused(source))
- (*voice)->Source = NULL;
- else
- CalcSourceParams(*voice, ctx, force);
+ if((source=(*voice)->Source) != NULL)
+ CalcSourceParams(*voice, source, ctx, force);
}
}
IncrementRef(&ctx->UpdateCount);
@@ -1423,13 +1419,15 @@ void aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
voice_end = voice + ctx->VoiceCount;
for(;voice != voice_end;++voice)
{
- ALboolean IsVoiceInit = ((*voice)->Step > 0);
source = (*voice)->Source;
- if(IsVoiceInit && source &&
- ATOMIC_LOAD(&source->state, almemory_order_relaxed) == AL_PLAYING)
+ if(source && ATOMIC_LOAD(&(*voice)->Playing, almemory_order_relaxed) &&
+ (*voice)->Step > 0)
{
if(!MixSource(*voice, source, device, SamplesToDo))
+ {
(*voice)->Source = NULL;
+ ATOMIC_STORE(&(*voice)->Playing, false, almemory_order_release);
+ }
}
}
@@ -1596,6 +1594,7 @@ void aluHandleDisconnect(ALCdevice *device)
{
ALsource *source = (*voice)->Source;
(*voice)->Source = NULL;
+ ATOMIC_STORE(&(*voice)->Playing, false, almemory_order_release);
if(source)
{