From 35c392463ec853fa0420fc9faeaf66abf76ecdd1 Mon Sep 17 00:00:00 2001 From: Karl Tomlinson Date: Thu, 10 Aug 2023 11:18:39 +0000 Subject: [PATCH] Bug 1358149 switch inexact cmath function usage in Web Audio to math.h r=padenot This will facilitate switching these functions to fdlibm, which maps to math.h. Depends on D185781 Differential Revision: https://phabricator.services.mozilla.com/D185782 --- dom/media/webaudio/BiquadFilterNode.cpp | 2 +- dom/media/webaudio/WebAudioUtils.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dom/media/webaudio/BiquadFilterNode.cpp b/dom/media/webaudio/BiquadFilterNode.cpp index 772043a5f21e8..a950f85823946 100644 --- a/dom/media/webaudio/BiquadFilterNode.cpp +++ b/dom/media/webaudio/BiquadFilterNode.cpp @@ -35,7 +35,7 @@ static void SetParamsOnBiquad(WebCore::Biquad& aBiquad, float aSampleRate, double normalizedFrequency = aFrequency / nyquist; if (aDetune) { - normalizedFrequency *= std::exp2(aDetune / 1200); + normalizedFrequency *= exp2(aDetune / 1200); } switch (aType) { diff --git a/dom/media/webaudio/WebAudioUtils.h b/dom/media/webaudio/WebAudioUtils.h index 0b01efde69cac..c27b51787a50f 100644 --- a/dom/media/webaudio/WebAudioUtils.h +++ b/dom/media/webaudio/WebAudioUtils.h @@ -59,21 +59,21 @@ void ConvertAudioTimelineEventToTicks(AudioTimelineEvent& aEvent, * value is 0. */ inline float ConvertLinearToDecibels(float aLinearValue, float aMinDecibels) { - return aLinearValue ? 20.0f * std::log10(aLinearValue) : aMinDecibels; + return aLinearValue ? 20.0f * log10f(aLinearValue) : aMinDecibels; } /** * Converts a decibel value to a linear value. */ inline float ConvertDecibelsToLinear(float aDecibels) { - return std::pow(10.0f, 0.05f * aDecibels); + return powf(10.0f, 0.05f * aDecibels); } /** * Converts a decibel to a linear value. */ inline float ConvertDecibelToLinear(float aDecibel) { - return std::pow(10.0f, 0.05f * aDecibel); + return powf(10.0f, 0.05f * aDecibel); } inline void FixNaN(double& aDouble) { @@ -84,7 +84,7 @@ inline void FixNaN(double& aDouble) { inline double DiscreteTimeConstantForSampleRate(double timeConstant, double sampleRate) { - return 1.0 - std::exp(-1.0 / (sampleRate * timeConstant)); + return 1.0 - exp(-1.0 / (sampleRate * timeConstant)); } inline bool IsTimeValid(double aTime) {