Ensure voices has been updated once before mixing them

Sometimes the mixer is temporarily prevented from applying updates, when
multiple sources need to be updated simultaneously for example, but does not
prevent mixing. If the mixer runs during that time and a voice was just
started, it would've mixed the voice without any internal properties being set
for it.
This commit is contained in:
Chris Robinson 2016-06-16 18:22:01 -07:00
parent 697ee19f71
commit 80da138d7f
2 changed files with 10 additions and 2 deletions

View File

@ -1460,8 +1460,9 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
voice_end = voice + ctx->VoiceCount; voice_end = voice + ctx->VoiceCount;
for(;voice != voice_end;++voice) for(;voice != voice_end;++voice)
{ {
ALboolean IsVoiceInit = (voice->Step > 0);
source = voice->Source; source = voice->Source;
if(source && source->state == AL_PLAYING) if(source && source->state == AL_PLAYING && IsVoiceInit)
MixSource(voice, source, device, SamplesToDo); MixSource(voice, source, device, SamplesToDo);
} }

View File

@ -2986,10 +2986,17 @@ ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state)
voice->Source = Source; voice->Source = Source;
} }
/* Clear previous samples if playback is discontinuous. */
if(discontinuity) if(discontinuity)
{
/* Clear previous samples if playback is discontinuous. */
memset(voice->PrevSamples, 0, sizeof(voice->PrevSamples)); memset(voice->PrevSamples, 0, sizeof(voice->PrevSamples));
/* Clear the stepping value so the mixer knows not to mix this
* until the update gets applied.
*/
voice->Step = 0;
}
voice->Moving = AL_FALSE; voice->Moving = AL_FALSE;
for(i = 0;i < MAX_INPUT_CHANNELS;i++) for(i = 0;i < MAX_INPUT_CHANNELS;i++)
{ {