aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2013-12-01 01:03:55 -0800
committerChris Robinson <[email protected]>2013-12-01 01:03:55 -0800
commit3f5914e0949ee12b504ee7254990e007ff8057ef (patch)
tree413b131cae84e4c2017e228ba18af8422f1cbcb8
parent517be463ae0ebc2ca15a4ba48d3b969a264183f2 (diff)
Simplify dummy synth processing loop
-rw-r--r--OpenAL32/alMidi.c42
1 files changed, 15 insertions, 27 deletions
diff --git a/OpenAL32/alMidi.c b/OpenAL32/alMidi.c
index e0d07fe8..01fd13a9 100644
--- a/OpenAL32/alMidi.c
+++ b/OpenAL32/alMidi.c
@@ -530,41 +530,29 @@ static void DSynth_processQueue(DSynth *self, ALuint64 time)
static void DSynth_process(DSynth *self, ALuint SamplesToDo, ALfloatBUFFERSIZE*restrict UNUSED(DryBuffer))
{
MidiSynth *synth = STATIC_CAST(MidiSynth, self);
- ALuint total = 0;
- if(synth->State == AL_INITIAL)
- return;
- if(synth->State == AL_PAUSED)
+ if(synth->State != AL_PLAYING)
return;
- while(total < SamplesToDo)
+ synth->SamplesSinceLast += SamplesToDo;
+ synth->SamplesToNext -= SamplesToDo;
+ while(synth->SamplesToNext < 1.0f)
{
- if(synth->SamplesToNext >= 1.0)
+ ALuint64 time = synth->NextEvtTime;
+ if(time == UINT64_MAX)
{
- ALuint todo = minu(SamplesToDo - total, fastf2u(synth->SamplesToNext));
-
- total += todo;
- synth->SamplesSinceLast += todo;
- synth->SamplesToNext -= todo;
+ synth->SamplesToNext = 0.0;
+ break;
}
- else
- {
- ALuint64 time = synth->NextEvtTime;
- if(time == UINT64_MAX)
- {
- synth->SamplesSinceLast += SamplesToDo-total;
- break;
- }
- synth->SamplesSinceLast -= (time - synth->LastEvtTime) * synth->SamplesPerTick;
- synth->SamplesSinceLast = maxd(synth->SamplesSinceLast, 0.0);
- synth->LastEvtTime = time;
- DSynth_processQueue(self, time);
+ synth->SamplesSinceLast -= (time - synth->LastEvtTime) * synth->SamplesPerTick;
+ synth->SamplesSinceLast = maxd(synth->SamplesSinceLast, 0.0);
+ synth->LastEvtTime = time;
+ DSynth_processQueue(self, time);
- synth->NextEvtTime = MidiSynth_getNextEvtTime(synth);
- if(synth->NextEvtTime != UINT64_MAX)
- synth->SamplesToNext += (synth->NextEvtTime - synth->LastEvtTime) * synth->SamplesPerTick;
- }
+ synth->NextEvtTime = MidiSynth_getNextEvtTime(synth);
+ if(synth->NextEvtTime != UINT64_MAX)
+ synth->SamplesToNext += (synth->NextEvtTime - synth->LastEvtTime) * synth->SamplesPerTick;
}
}