Changeset 287854 in webkit
- Timestamp:
- Jan 10, 2022, 1:45:01 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 3 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/webaudio/Panner/panner-cone-gain-nan-expected.txt (added)
-
LayoutTests/webaudio/Panner/panner-cone-gain-nan.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/platform/audio/Cone.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r287847 r287854 1 2022-01-10 Chris Dumez <cdumez@apple.com> 2 3 https://brianpeiris.github.io/spatial-audio-test/?ramped stops playing after a few seconds 4 https://bugs.webkit.org/show_bug.cgi?id=234979 5 6 Reviewed by Eric Carlson. 7 8 Add layout test coverage. 9 10 * webaudio/Panner/panner-cone-gain-nan-expected.txt: Added. 11 * webaudio/Panner/panner-cone-gain-nan.html: Added. 12 1 13 2022-01-10 Cathie Chen <cathiechen@igalia.com> 2 14 -
trunk/Source/WebCore/ChangeLog
r287849 r287854 1 2022-01-10 Chris Dumez <cdumez@apple.com> 2 3 https://brianpeiris.github.io/spatial-audio-test/?ramped stops playing after a few seconds 4 https://bugs.webkit.org/show_bug.cgi?id=234979 5 6 Reviewed by Eric Carlson. 7 8 In ConeEffect::gain(), due to precision issues and with certain panner node parameters, it was possible for 9 `sourceToListener.dot(sourceOrientation)` to return a value that is very slightly outside the [-1.0, 1.0] 10 range. We would then call `acos()` on the dot product and it would thus return NaN. 11 12 To addresss this, we now make sure the clamp the dot product to the expected range before calling acos(). 13 14 I also made the following stylistic changes: 15 - Drop unnecessary normalizedSourceOrientation local variable since the sourceOrientation paramter is not const 16 - Add missing curly brackets in if conditions with more than one lines (due to comments) 17 - Call rad2deg() for readability instead of duplicating its logic here 18 19 Test: webaudio/Panner/panner-cone-gain-nan.html 20 21 * platform/audio/Cone.cpp: 22 (WebCore::ConeEffect::gain const): 23 1 24 2022-01-10 Wenson Hsieh <wenson_hsieh@apple.com> 2 25 -
trunk/Source/WebCore/platform/audio/Cone.cpp
r283740 r287854 47 47 sourceToListener.normalize(); 48 48 49 FloatPoint3D normalizedSourceOrientation = sourceOrientation; 50 normalizedSourceOrientation.normalize(); 49 sourceOrientation.normalize(); 50 51 // Due to precision issues, the dot product may be very slightly outside the range [-1.0, 1.0], which would 52 // acos() to return NaN. For this reason, we have to make sure we clamp the dot product before calling acos(). 53 auto dotProduct = clampTo(sourceToListener.dot(sourceOrientation), -1.0, 1.0); 51 54 52 55 // Angle between the source orientation vector and the source-listener vector 53 double dotProduct = sourceToListener.dot(normalizedSourceOrientation); 54 double angle = 180.0 * acos(dotProduct) / piDouble; 56 double angle = rad2deg(acos(dotProduct)); 55 57 double absAngle = fabs(angle); 56 58 … … 60 62 double gain = 1.0; 61 63 62 if (absAngle <= absInnerAngle) 64 if (absAngle <= absInnerAngle) { 63 65 // No attenuation 64 66 gain = 1.0; 65 else if (absAngle >= absOuterAngle)67 } else if (absAngle >= absOuterAngle) { 66 68 // Max attenuation 67 69 gain = m_outerGain; 68 else {70 } else { 69 71 // Between inner and outer cones 70 72 // inner -> outer, x goes from 0 -> 1
Note:
See TracChangeset
for help on using the changeset viewer.