Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
https://brianpeiris.github.io/spatial-audio-test/?ramped stops playin…
…g after a few seconds https://bugs.webkit.org/show_bug.cgi?id=234979 Reviewed by Eric Carlson. Source/WebCore: In ConeEffect::gain(), due to precision issues and with certain panner node parameters, it was possible for `sourceToListener.dot(sourceOrientation)` to return a value that is very slightly outside the [-1.0, 1.0] range. We would then call `acos()` on the dot product and it would thus return NaN. To addresss this, we now make sure the clamp the dot product to the expected range before calling acos(). I also made the following stylistic changes: - Drop unnecessary normalizedSourceOrientation local variable since the sourceOrientation paramter is not const - Add missing curly brackets in if conditions with more than one lines (due to comments) - Call rad2deg() for readability instead of duplicating its logic here Test: webaudio/Panner/panner-cone-gain-nan.html * platform/audio/Cone.cpp: (WebCore::ConeEffect::gain const): LayoutTests: Add layout test coverage. * webaudio/Panner/panner-cone-gain-nan-expected.txt: Added. * webaudio/Panner/panner-cone-gain-nan.html: Added. Canonical link: https://commits.webkit.org/245900@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@287854 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
with
95 additions
and 7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,10 @@ | ||
Tests that precision issues do not cause ConeEffect::gain() to return NaN | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS data.some(isNaN) is false | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,41 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="../../resources/js-test.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
description("Tests that precision issues do not cause ConeEffect::gain() to return NaN"); | ||
jsTestIsAsync = true; | ||
|
||
function test() { | ||
const audioContext = new OfflineAudioContext(1, 44100, 44100); | ||
|
||
const panner = audioContext.createPanner(); | ||
panner.panningModel = "HRTF"; | ||
panner.refDistance = 50; | ||
panner.coneInnerAngle = 0; | ||
panner.coneOuterAngle = 180; | ||
panner.coneOuterGain = 0.25; | ||
|
||
const source = new ConstantSourceNode(audioContext); | ||
source.connect(panner); | ||
panner.connect(audioContext.destination); | ||
|
||
audioContext.listener.setPosition(203.4781799316, 0, 200); | ||
panner.setPosition(121.7528991699, 0, 137.7344207764); | ||
panner.setOrientation(0.7954952121, 0, 0.6058534384); | ||
|
||
source.start(); | ||
audioContext.startRendering().then((buffer) => { | ||
data = buffer.getChannelData(0); | ||
shouldBeFalse("data.some(isNaN)"); | ||
finishJSTest(); | ||
}); | ||
} | ||
|
||
onload = test; | ||
|
||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters