From 513c18fdc4d0d9184e061570209eb59f4ad0e392 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 25 Feb 2017 16:46:30 -0800 Subject: Ensure a non-playing or -paused source does not use a mixing voice --- Alc/ALu.c | 5 ++++- Alc/mixer.c | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'Alc') diff --git a/Alc/ALu.c b/Alc/ALu.c index 5a5e6fdf..3b83711f 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -1427,7 +1427,10 @@ void aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size) source = (*voice)->Source; if(IsVoiceInit && source && ATOMIC_LOAD(&source->state, almemory_order_relaxed) == AL_PLAYING) - MixSource(*voice, source, device, SamplesToDo); + { + if(!MixSource(*voice, source, device, SamplesToDo)) + (*voice)->Source = NULL; + } } /* effect slot processing */ diff --git a/Alc/mixer.c b/Alc/mixer.c index 46ca0892..be09ed67 100644 --- a/Alc/mixer.c +++ b/Alc/mixer.c @@ -366,7 +366,7 @@ static const ALfloat *DoFilters(ALfilterState *lpfilter, ALfilterState *hpfilter } -void MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALsizei SamplesToDo) +ALboolean MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALsizei SamplesToDo) { ResamplerFunc Resample; ALbufferlistitem *BufferListItem; @@ -685,4 +685,5 @@ void MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALsizei Samp ATOMIC_STORE(&Source->current_buffer, BufferListItem, almemory_order_relaxed); ATOMIC_STORE(&Source->position, DataPosInt, almemory_order_relaxed); ATOMIC_STORE(&Source->position_fraction, DataPosFrac, almemory_order_release); + return State == AL_PLAYING; } -- cgit v1.2.3