Bug 1047831. r=ehsan, a=sledru
authorPaul Adenot <paul@paul.cx>
Thu, 07 Aug 2014 17:02:36 +0200
changeset 208282 0c488a1d2142
parent 208281 3f7ae08da07f
child 208283 6b9281a057b7
push id3800
push userryanvm@gmail.com
push date2014-08-09 19:35 +0000
treeherdermozilla-beta@6b9281a057b7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan, sledru
bugs1047831
milestone32.0
Bug 1047831. r=ehsan, a=sledru
content/media/AudioEventTimeline.h
--- a/content/media/AudioEventTimeline.h
+++ b/content/media/AudioEventTimeline.h
@@ -2,16 +2,17 @@
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef AudioEventTimeline_h_
 #define AudioEventTimeline_h_
 
+#include <algorithm>
 #include "mozilla/Assertions.h"
 #include "mozilla/FloatingPoint.h"
 #include "mozilla/TypedEnum.h"
 #include "mozilla/PodOperations.h"
 
 #include "nsTArray.h"
 #include "math.h"
 
@@ -416,18 +417,17 @@ public:
   }
 
   static float ExtractValueFromCurve(double startTime, float* aCurve, uint32_t aCurveLength, double duration, double t)
   {
     if (t >= startTime + duration) {
       // After the duration, return the last curve value
       return aCurve[aCurveLength - 1];
     }
-    double ratio = (t - startTime) / duration;
-    MOZ_ASSERT(ratio >= 0.0, "Ratio can never be negative here");
+    double ratio = std::max((t - startTime) / duration, 0.0);
     if (ratio >= 1.0) {
       return aCurve[aCurveLength - 1];
     }
     return aCurve[uint32_t(aCurveLength * ratio)];
   }
 
   void ConvertEventTimesToTicks(int64_t (*aConvertor)(double aTime, void* aClosure), void* aClosure,
                                 int32_t aSampleRate)