Bug 997870 - Optimize OscillatorNodeEngine::ComputeCustom a little. r=karlt

--HG--
extra : rebase_source : 6d88a2154196c8c34521e246061e9581b98f70a1
This commit is contained in:
Paul Adenot 2014-12-10 15:34:14 +01:00
parent be30f76960
commit e2587f5bd7

View File

@ -151,15 +151,15 @@ public:
{
double frequency, detune;
bool simpleFrequency = mFrequency.HasSimpleValue();
bool simpleDetune = mDetune.HasSimpleValue();
// Shortcut if frequency-related AudioParam are not automated, and we
// already have computed the frequency information and related parameters.
if (simpleFrequency && simpleDetune && !mRecomputeParameters) {
if (!ParametersMayNeedUpdate()) {
return;
}
bool simpleFrequency = mFrequency.HasSimpleValue();
bool simpleDetune = mDetune.HasSimpleValue();
if (simpleFrequency) {
frequency = mFrequency.GetValue();
} else {
@ -212,6 +212,13 @@ public:
}
}
bool ParametersMayNeedUpdate()
{
return !mDetune.HasSimpleValue() ||
!mFrequency.HasSimpleValue() ||
mRecomputeParameters;
}
void ComputeCustom(float* aOutput,
StreamTime ticks,
uint32_t aStart,
@ -231,12 +238,22 @@ public:
// mPhase runs [0,periodicWaveSize) here instead of [0,2*M_PI).
float basePhaseIncrement = mPeriodicWave->rateScale();
UpdateParametersIfNeeded(ticks, aStart);
bool parametersMayNeedUpdate = ParametersMayNeedUpdate();
mPeriodicWave->waveDataForFundamentalFrequency(mFinalFrequency,
lowerWaveData,
higherWaveData,
tableInterpolationFactor);
for (uint32_t i = aStart; i < aEnd; ++i) {
UpdateParametersIfNeeded(ticks, i);
mPeriodicWave->waveDataForFundamentalFrequency(mFinalFrequency,
lowerWaveData,
higherWaveData,
tableInterpolationFactor);
if (parametersMayNeedUpdate) {
mPeriodicWave->waveDataForFundamentalFrequency(mFinalFrequency,
lowerWaveData,
higherWaveData,
tableInterpolationFactor);
UpdateParametersIfNeeded(ticks, i);
}
// Bilinear interpolation between adjacent samples in each table.
float floorPhase = floorf(mPhase);
uint32_t j1 = floorPhase;