+2012-02-23 Raymond Toy <rtoy@google.com>
+
+ Use MathExtras round() in timeToSampleFrame
+ https://bugs.webkit.org/show_bug.cgi?id=79281
+
+ Reviewed by Chris Rogers.
+
+ No new tests. Existing tests cover this change.
+
+ * platform/audio/AudioUtilities.cpp:
+ (WebCore::AudioUtilities::timeToSampleFrame): Use round().
+
2012-02-23 Greg Billock <gbillock@google.com>
Don't clear IntentRequest callback pointers on stop()
return 1 - powf(1 / 2.718282f, 1 / (sampleRate * timeConstant));
}
-#if OS(WINDOWS) && COMPILER(MSVC) && !_M_IX86_FP
-// When compiling with MSVC with x87 FPU instructions using 80-bit
-// floats, we want very precise control over the arithmetic so that
-// rounding is done according to the IEEE 754 specification for
-// single- and double-precision floats. We want each operation to be
-// done with specified arithmetic precision and rounding consistent
-// with gcc, not extended to 80 bits automatically.
-//
-// These pragmas are equivalent to /fp:strict flag, but we only need
-// it for the function here. (Using fp:strict everywhere can have
-// severe impact on floating point performance.)
-#pragma float_control(push)
-#pragma float_control(precise, on)
-#pragma fenv_access(on)
-#pragma float_control(except, on)
-#endif
-
size_t timeToSampleFrame(double time, double sampleRate)
{
- // DO NOT CONSOLIDATE THESE ASSIGNMENTS INTO ONE! When compiling
- // with Visual Studio, these assignments force the rounding of
- // each operation according to IEEE 754, instead of leaving
- // intermediate results in 80-bit precision which is not
- // consistent with IEEE 754 double-precision rounding.
- double r = time * sampleRate;
- r += 0.5;
- return static_cast<size_t>(r);
+ return static_cast<size_t>(round(time * sampleRate));
}
-#if OS(WINDOWS) && COMPILER(MSVC) && !_M_IX86_FP
-// Restore normal floating-point semantics.
-#pragma float_control(pop)
-#endif
} // AudioUtilites
} // WebCore