Modified: trunk/LayoutTests/imported/w3c/ChangeLog (266468 => 266469)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2020-09-02 16:19:52 UTC (rev 266468)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2020-09-02 16:38:46 UTC (rev 266469)
@@ -1,3 +1,14 @@
+2020-09-02 Chris Dumez <[email protected]>
+
+ Implement event convergence for AudioParam.setTargetAtTime()
+ https://bugs.webkit.org/show_bug.cgi?id=216064
+
+ Reviewed by Geoffrey Garen.
+
+ Rebaseline test that is now passing.
+
+ * web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/set-target-conv-expected.txt:
+
2020-09-02 Youenn Fablet <[email protected]>
Introduce a C++ chain of operations in RTCPeerConnection
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/set-target-conv-expected.txt (266468 => 266469)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/set-target-conv-expected.txt 2020-09-02 16:19:52 UTC (rev 266468)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/set-target-conv-expected.txt 2020-09-02 16:38:46 UTC (rev 266469)
@@ -7,17 +7,7 @@
PASS src.offset.setTargetAtTime(0.5, 0.01, 0.01) did not throw an exception.
PASS src.offset.setValueAtTime(0.5, 0.15) did not throw an exception.
PASS src.offset.linearRampToValueAtTime(1, 0.151) did not throw an exception.
-FAIL X output[1072:] does not equal [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5...] with an element-wise tolerance of {"absoluteThreshold":0,"relativeThreshold":0.0000041724}.
- Index Actual Expected AbsError RelError Test threshold
- [0] 5.0000238418579102e-1 5.0000000000000000e-1 2.3841857910156250e-6 4.7683715820312500e-6 2.0862000000000000e-6
- [1] 5.0000238418579102e-1 5.0000000000000000e-1 2.3841857910156250e-6 4.7683715820312500e-6 2.0862000000000000e-6
- [2] 5.0000238418579102e-1 5.0000000000000000e-1 2.3841857910156250e-6 4.7683715820312500e-6 2.0862000000000000e-6
- [3] 5.0000238418579102e-1 5.0000000000000000e-1 2.3841857910156250e-6 4.7683715820312500e-6 2.0862000000000000e-6
- [4] 5.0000238418579102e-1 5.0000000000000000e-1 2.3841857910156250e-6 4.7683715820312500e-6 2.0862000000000000e-6
- ...and 123 more errors.
- Max AbsError of 2.3841857910156250e-6 at index of 0.
- Max RelError of 4.7683715820312500e-6 at index of 0.
- assert_true: expected true got false
-FAIL < [convergence handled correctly] 1 out of 5 assertions were failed. assert_true: expected true got false
-FAIL # AUDIT TASK RUNNER FINISHED: 1 out of 1 tasks were failed. assert_true: expected true got false
+PASS output[1072:] equals [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5...] with an element-wise tolerance of {"absoluteThreshold":0,"relativeThreshold":0.0000041724}.
+PASS < [convergence handled correctly] All assertions passed. (total 5 assertions)
+PASS # AUDIT TASK RUNNER FINISHED: 1 tasks ran successfully.
Modified: trunk/Source/WebCore/ChangeLog (266468 => 266469)
--- trunk/Source/WebCore/ChangeLog 2020-09-02 16:19:52 UTC (rev 266468)
+++ trunk/Source/WebCore/ChangeLog 2020-09-02 16:38:46 UTC (rev 266469)
@@ -1,3 +1,19 @@
+2020-09-02 Chris Dumez <[email protected]>
+
+ Implement event convergence for AudioParam.setTargetAtTime()
+ https://bugs.webkit.org/show_bug.cgi?id=216064
+
+ Reviewed by Geoffrey Garen.
+
+ Implement event convergence for AudioParam.setTargetAtTime(). This is to match Chromium's
+ behavior and pass the corresponding WPT test.
+
+ No new tests, rebaselined existing test.
+
+ * Modules/webaudio/AudioParamTimeline.cpp:
+ (WebCore::hasSetTargetConverged):
+ (WebCore::AudioParamTimeline::valuesForTimeRangeImpl):
+
2020-09-02 Youenn Fablet <[email protected]>
Introduce a C++ chain of operations in RTCPeerConnection
Modified: trunk/Source/WebCore/Modules/webaudio/AudioParamTimeline.cpp (266468 => 266469)
--- trunk/Source/WebCore/Modules/webaudio/AudioParamTimeline.cpp 2020-09-02 16:19:52 UTC (rev 266468)
+++ trunk/Source/WebCore/Modules/webaudio/AudioParamTimeline.cpp 2020-09-02 16:38:46 UTC (rev 266469)
@@ -37,6 +37,32 @@
namespace WebCore {
+// Test that for a SetTarget event, the current value is close enough to the target value that
+// we can consider the event to have converged to the target.
+static bool hasSetTargetConverged(float value, float target, Seconds currentTime, Seconds startTime, double timeConstant)
+{
+ // For a SetTarget event, we want the event to terminate eventually so that we can stop using
+ // the timeline to compute the values.
+ constexpr float timeConstantsToConverge = 10;
+ constexpr float setTargetThreshold = 4.539992976248485e-05;
+
+ // Converged if enough time constants (|timeConstantsToConverge|) have passed since the start
+ // of the event.
+ if (currentTime.value() > startTime.value() + timeConstantsToConverge * timeConstant)
+ return true;
+
+ // If |target| is 0, converged if |value| is less than |setTargetThreshold|.
+ if (!target && std::abs(value) < setTargetThreshold)
+ return true;
+
+ // If |target| is not zero, converged if relative difference between |value|
+ // and |target| is small. That is |target - value| / |target| < |setTargetThreshold|.
+ if (target && std::abs(target - value) < setTargetThreshold * std::abs(value))
+ return true;
+
+ return false;
+}
+
ExceptionOr<void> AudioParamTimeline::setValueAtTime(float value, Seconds time)
{
return insertEvent(ParamEvent(ParamEvent::SetValue, value, time, 0, { }, { }));
@@ -292,9 +318,18 @@
float timeConstant = event.timeConstant();
float discreteTimeConstant = static_cast<float>(AudioUtilities::discreteTimeConstantForSampleRate(timeConstant, controlRate));
- for (; writeIndex < fillToFrame; ++writeIndex) {
- values[writeIndex] = value;
- value += (target - value) * discreteTimeConstant;
+ // If the value is close enough to the target, just fill in the data
+ // with the target value.
+ if (hasSetTargetConverged(value, target, currentTime, time1, timeConstant)) {
+ for (; writeIndex < fillToFrame; ++writeIndex)
+ values[writeIndex] = target;
+ value = target;
+ } else {
+ // Serially process remaining values.
+ for (; writeIndex < fillToFrame; ++writeIndex) {
+ values[writeIndex] = value;
+ value += (target - value) * discreteTimeConstant;
+ }
}
break;