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 183792 3b65e1a1c52a
parent 183791 5f78c1ba85e3
child 183793 034a63535df0
push id3485
push userrgiles@mozilla.com
push date2014-04-17 16:56 +0000
treeherdermozilla-beta@3b65e1a1c52a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot, sledru
bugs995289
milestone29.0
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] +