Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(998)

Unified Diff: third_party/WebKit/Source/platform/audio/Distance.cpp

Issue 2389133006: Clamp PannerNode rolloffFactor to nominal range (Closed)
Patch Set: Clean up test Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/webaudio/panner-rolloff-clamping.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/audio/Distance.cpp
diff --git a/third_party/WebKit/Source/platform/audio/Distance.cpp b/third_party/WebKit/Source/platform/audio/Distance.cpp
index 93f6bc685aa79720e6e022fe882d5f7578bd0abd..7cc29ed2f4e60a44e052d09859b816fab30d071f 100644
--- a/third_party/WebKit/Source/platform/audio/Distance.cpp
+++ b/third_party/WebKit/Source/platform/audio/Distance.cpp
@@ -28,6 +28,7 @@
#include "platform/audio/Distance.h"
#include "wtf/Assertions.h"
+#include "wtf/MathExtras.h"
#include <math.h>
#include <algorithm>
@@ -64,17 +65,18 @@ double DistanceEffect::linearGain(double distance) {
// We want a gain that decreases linearly from m_refDistance to
// m_maxDistance. The gain is 1 at m_refDistance.
return (1.0 -
- m_rolloffFactor * (distance - m_refDistance) /
+ clampTo(m_rolloffFactor, 0.0, 1.0) * (distance - m_refDistance) /
(m_maxDistance - m_refDistance));
}
double DistanceEffect::inverseGain(double distance) {
return m_refDistance /
- (m_refDistance + m_rolloffFactor * (distance - m_refDistance));
+ (m_refDistance +
+ clampTo(m_rolloffFactor, 0.0) * (distance - m_refDistance));
}
double DistanceEffect::exponentialGain(double distance) {
- return pow(distance / m_refDistance, -m_rolloffFactor);
+ return pow(distance / m_refDistance, -clampTo(m_rolloffFactor, 0.0));
}
} // namespace blink
« no previous file with comments | « third_party/WebKit/LayoutTests/webaudio/panner-rolloff-clamping.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698