Simplify dummy synth processing loop

This commit is contained in:
Chris Robinson 2013-12-01 01:03:55 -08:00
parent 517be463ae
commit 3f5914e094

View File

@ -530,29 +530,18 @@ static void DSynth_processQueue(DSynth *self, ALuint64 time)
static void DSynth_process(DSynth *self, ALuint SamplesToDo, ALfloatBUFFERSIZE*restrict UNUSED(DryBuffer)) static void DSynth_process(DSynth *self, ALuint SamplesToDo, ALfloatBUFFERSIZE*restrict UNUSED(DryBuffer))
{ {
MidiSynth *synth = STATIC_CAST(MidiSynth, self); MidiSynth *synth = STATIC_CAST(MidiSynth, self);
ALuint total = 0;
if(synth->State == AL_INITIAL) if(synth->State != AL_PLAYING)
return;
if(synth->State == AL_PAUSED)
return; return;
while(total < SamplesToDo) synth->SamplesSinceLast += SamplesToDo;
{ synth->SamplesToNext -= SamplesToDo;
if(synth->SamplesToNext >= 1.0) while(synth->SamplesToNext < 1.0f)
{
ALuint todo = minu(SamplesToDo - total, fastf2u(synth->SamplesToNext));
total += todo;
synth->SamplesSinceLast += todo;
synth->SamplesToNext -= todo;
}
else
{ {
ALuint64 time = synth->NextEvtTime; ALuint64 time = synth->NextEvtTime;
if(time == UINT64_MAX) if(time == UINT64_MAX)
{ {
synth->SamplesSinceLast += SamplesToDo-total; synth->SamplesToNext = 0.0;
break; break;
} }
@ -565,7 +554,6 @@ static void DSynth_process(DSynth *self, ALuint SamplesToDo, ALfloatBUFFERSIZE*r
if(synth->NextEvtTime != UINT64_MAX) if(synth->NextEvtTime != UINT64_MAX)
synth->SamplesToNext += (synth->NextEvtTime - synth->LastEvtTime) * synth->SamplesPerTick; synth->SamplesToNext += (synth->NextEvtTime - synth->LastEvtTime) * synth->SamplesPerTick;
} }
}
} }