Bug 995289 - Use fmod to wrap custom waveform phase. r=padenot a=sledru
authorRalph Giles <giles@mozilla.com>
Mon, 14 Apr 2014 19:12:13 -0700
changeset 192917 eaa1f0c148eca5f315e8716ede7c10e1a0d22a39
parent 192916 66d3dcc2bd4709f2e2f7cdf89385134a4dbd17cd
child 192918 05e7a88563b691c4581da45b9e03d717f0f50f3a
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot, sledru
bugs995289
milestone30.0a2
Bug 995289 - Use fmod to wrap custom waveform phase. r=padenot a=sledru
content/media/webaudio/OscillatorNode.cpp
--- a/content/media/webaudio/OscillatorNode.cpp
+++ b/content/media/webaudio/OscillatorNode.cpp
@@ -381,19 +381,17 @@ public:
     for (uint32_t i = aStart; i < aEnd; ++i) {
       UpdateParametersIfNeeded(ticks, i);
       mPeriodicWave->waveDataForFundamentalFrequency(mFinalFrequency,
                                                      lowerWaveData,
                                                      higherWaveData,
                                                      tableInterpolationFactor);
       // mPhase runs 0..periodicWaveSize here instead of 0..2*M_PI.
       mPhase += periodicWaveSize * mFinalFrequency * rate;
-      if (mPhase >= periodicWaveSize) {
-        mPhase -= periodicWaveSize;
-      }
+      mPhase = fmod(mPhase, periodicWaveSize);
       // Bilinear interpolation between adjacent samples in each table.
       uint32_t j1 = floor(mPhase);
       uint32_t j2 = j1 + 1;
       if (j2 >= periodicWaveSize) {
         j2 -= periodicWaveSize;
       }
       float sampleInterpolationFactor = mPhase - j1;
       float lower = sampleInterpolationFactor * lowerWaveData[j1] +