Skip to content

Commit

Permalink
Bug 1358149 switch inexact cmath function usage in Web Audio to math.…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
karlt committed Aug 10, 2023
1 parent d710369 commit 35c3924
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dom/media/webaudio/BiquadFilterNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions dom/media/webaudio/WebAudioUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down

0 comments on commit 35c3924

Please sign in to comment.