Title: [268103] trunk
Revision
268103
Author
cdu...@apple.com
Date
2020-10-06 17:36:21 -0700 (Tue, 06 Oct 2020)

Log Message

Add implementation for AudioWorkletGlobalScope.registerProcessor()
https://bugs.webkit.org/show_bug.cgi?id=217405

Reviewed by Geoff Garen.

LayoutTests/imported/w3c:

Rebaseline WPT tests as we are now passing more checks.

* web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-audioworklet-connections.https-expected.txt:
* web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-audioworklet.https-expected.txt:
* web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworklet-audioparam-iterable.https-expected.txt:
* web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworklet-audioparam.https-expected.txt:
* web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletglobalscope-sample-rate.https-expected.txt:
* web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-construction.https-expected.txt:

Source/WebCore:

Add implementation for AudioWorkletGlobalScope.registerProcessor() that matches very closely
the specification at:
- https://www.w3.org/TR/webaudio/#dom-audioworkletglobalscope-registerprocessor

Also update the AudioWorkletNode constructor implementation as per:
- https://www.w3.org/TR/webaudio/#AudioWorkletNode-constructors

Now that the AudioWorklet is able to register a processor and AudioParamDescriptors, the
AudioWorkletNode constructor is able to make sure that a processor with the given name was
indeed registered. We are also able to construct the AudioParam objects based on the
AudioParamDescriptors provided when registering the processor.

Note that even though it is now possible to register an AudioWorkletProcessor, it is still
not used to process the audio. An AudioWorkletNode currently only outputs silence. This will
be addresssed in a future patch.

No new tests, rebaselined existing tests.

* CMakeLists.txt:
* DerivedSources-input.xcfilelist:
* DerivedSources-output.xcfilelist:
* DerivedSources.make:
* Modules/webaudio/AudioParam.h:
* Modules/webaudio/AudioParam.idl:
* Modules/webaudio/AudioParamDescriptor.h: Copied from Source/WebCore/Modules/webaudio/AudioWorkletGlobalScope.idl.
(WebCore::AudioParamDescriptor::isolatedCopy const):
* Modules/webaudio/AudioParamDescriptor.idl: Copied from Source/WebCore/Modules/webaudio/AudioWorkletGlobalScope.idl.
* Modules/webaudio/AudioWorkletGlobalScope.cpp:
(WebCore::AudioWorkletGlobalScope::registerProcessor):
* Modules/webaudio/AudioWorkletGlobalScope.h:
* Modules/webaudio/AudioWorkletGlobalScope.idl:
* Modules/webaudio/AudioWorkletMessagingProxy.cpp:
(WebCore::AudioWorkletMessagingProxy::AudioWorkletMessagingProxy):
(WebCore::AudioWorkletMessagingProxy::postTaskToAudioWorklet):
* Modules/webaudio/AudioWorkletMessagingProxy.h:
* Modules/webaudio/AudioWorkletNode.cpp:
(WebCore::AudioWorkletNode::create):
* Modules/webaudio/AudioWorkletThread.h:
(WebCore::AudioWorkletThread::messagingProxy):
* Modules/webaudio/AutomationRate.h: Copied from Source/WebCore/Modules/webaudio/AudioWorkletGlobalScope.idl.
* Modules/webaudio/AutomationRate.idl: Copied from Source/WebCore/Modules/webaudio/AudioWorkletGlobalScope.idl.
* Modules/webaudio/BaseAudioContext.cpp:
(WebCore::BaseAudioContext::addAudioParamDescriptors):
* Modules/webaudio/BaseAudioContext.h:
(WebCore::BaseAudioContext::parameterDescriptorMap const):
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/TestExpectations (268102 => 268103)


--- trunk/LayoutTests/TestExpectations	2020-10-07 00:23:27 UTC (rev 268102)
+++ trunk/LayoutTests/TestExpectations	2020-10-07 00:36:21 UTC (rev 268103)
@@ -321,12 +321,10 @@
 
 # These webaudio tests are timing out due to lack for support for AudioWorklet.
 imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/processing-after-resume.https.html [ Skip ]
-imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworklet-audioparam-size.https.html [ Skip ]
 imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworklet-messageport.https.html [ Skip ]
 imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworklet-postmessage-sharedarraybuffer.https.html [ Skip ]
 imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletglobalscope-timing-info.https.html [ Skip ]
 imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-automatic-pull.https.html [ Skip ]
-imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-channel-count.https.html [ Skip ]
 imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-onerror.https.html [ Skip ]
 imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-output-channel-count.https.html [ Skip ]
 imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletprocessor-options.https.html [ Skip ]

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (268102 => 268103)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-10-07 00:23:27 UTC (rev 268102)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-10-07 00:36:21 UTC (rev 268103)
@@ -1,3 +1,19 @@
+2020-10-06  Chris Dumez  <cdu...@apple.com>
+
+        Add implementation for AudioWorkletGlobalScope.registerProcessor()
+        https://bugs.webkit.org/show_bug.cgi?id=217405
+
+        Reviewed by Geoff Garen.
+
+        Rebaseline WPT tests as we are now passing more checks.
+
+        * web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-audioworklet-connections.https-expected.txt:
+        * web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-audioworklet.https-expected.txt:
+        * web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworklet-audioparam-iterable.https-expected.txt:
+        * web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworklet-audioparam.https-expected.txt:
+        * web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletglobalscope-sample-rate.https-expected.txt:
+        * web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-construction.https-expected.txt:
+
 2020-10-06  Alex Christensen  <achristen...@webkit.org>
 
         FileReader should transition to readyState DONE after last onprogress event

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-audioworklet-connections.https-expected.txt (268102 => 268103)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-audioworklet-connections.https-expected.txt	2020-10-07 00:23:27 UTC (rev 268102)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-audioworklet-connections.https-expected.txt	2020-10-07 00:36:21 UTC (rev 268103)
@@ -1,11 +1,17 @@
 
 PASS # AUDIT TASK RUNNER STARTED.
 PASS Executing "Create Test Worklet"
-FAIL Executing "AudioWorklet k-rate AudioParam" promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'kRateParam.automationRate = 'k-rate'')"
+PASS Executing "AudioWorklet k-rate AudioParam"
 PASS Audit report
 PASS > [Create Test Worklet]
 PASS   Construction of AudioWorklet resolved correctly.
 PASS < [Create Test Worklet] All assertions passed. (total 1 assertions)
 PASS > [AudioWorklet k-rate AudioParam]
-PASS # AUDIT TASK RUNNER FINISHED: 2 tasks ran successfully.
+FAIL X output should have contain at least one value different from 0. assert_true: expected true got false
+PASS    k-rate output [0: 127] contains only the constant 0.
+PASS    k-rate output [128: 255] contains only the constant 0.
+PASS    k-rate output [256: 383] contains only the constant 0.
+PASS    k-rate output [384: 511] contains only the constant 0.
+FAIL < [AudioWorklet k-rate AudioParam] 1 out of 5 assertions were failed. assert_true: expected true got false
+FAIL # AUDIT TASK RUNNER FINISHED: 1 out of 2 tasks were failed. assert_true: expected true got false
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-audioworklet.https-expected.txt (268102 => 268103)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-audioworklet.https-expected.txt	2020-10-07 00:23:27 UTC (rev 268102)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-audioworklet.https-expected.txt	2020-10-07 00:36:21 UTC (rev 268103)
@@ -1,11 +1,16 @@
 
 PASS # AUDIT TASK RUNNER STARTED.
 PASS Executing "Create Test Worklet"
-FAIL Executing "AudioWorklet k-rate AudioParam" promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'kRateParam.automationRate = 'k-rate'')"
+PASS Executing "AudioWorklet k-rate AudioParam"
 PASS Audit report
 PASS > [Create Test Worklet]
 PASS   Construction of AudioWorklet resolved correctly.
 PASS < [Create Test Worklet] All assertions passed. (total 1 assertions)
 PASS > [AudioWorklet k-rate AudioParam]
+PASS    k-rate output [0: 127] contains only the constant 0.
+PASS    k-rate output [128: 255] contains only the constant 0.
+PASS    k-rate output [256: 383] contains only the constant 0.
+PASS    k-rate output [384: 511] contains only the constant 0.
+PASS < [AudioWorklet k-rate AudioParam] All assertions passed. (total 4 assertions)
 PASS # AUDIT TASK RUNNER FINISHED: 2 tasks ran successfully.
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworklet-audioparam-iterable.https-expected.txt (268102 => 268103)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworklet-audioparam-iterable.https-expected.txt	2020-10-07 00:23:27 UTC (rev 268102)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworklet-audioparam-iterable.https-expected.txt	2020-10-07 00:36:21 UTC (rev 268103)
@@ -1,21 +1,62 @@
 
 PASS Creating an AudioWorkletNode with a set for
                     parameter descriptor worked
-FAIL Map match in size for set assert_equals: expected 3 but got 0
+PASS Map match in size for set
+PASS set: 你好 exists in both maps
+PASS Values for 你好.defaultValue match for set
+PASS Values for 你好.minValue match for set
+PASS Values for 你好.maxValue match for set
+PASS Values for 你好.automationRate match for set
+PASS set: a control-rate parameter exists in both maps
+PASS Values for a control-rate parameter.defaultValue match for set
+PASS Values for a control-rate parameter.minValue match for set
+PASS Values for a control-rate parameter.maxValue match for set
+PASS Values for a control-rate parameter.automationRate match for set
+PASS set: 🎶 exists in both maps
+PASS Values for 🎶.defaultValue match for set
+PASS Values for 🎶.minValue match for set
+PASS Values for 🎶.maxValue match for set
+PASS Values for 🎶.automationRate match for set
 PASS Creating an AudioWorkletNode with a array for
                     parameter descriptor worked
-FAIL Map match in size for array assert_equals: expected 3 but got 0
+PASS Map match in size for array
+PASS array: 你好 exists in both maps
+PASS Values for 你好.defaultValue match for array
+PASS Values for 你好.minValue match for array
+PASS Values for 你好.maxValue match for array
+PASS Values for 你好.automationRate match for array
+PASS array: a control-rate parameter exists in both maps
+PASS Values for a control-rate parameter.defaultValue match for array
+PASS Values for a control-rate parameter.minValue match for array
+PASS Values for a control-rate parameter.maxValue match for array
+PASS Values for a control-rate parameter.automationRate match for array
+PASS array: 🎶 exists in both maps
+PASS Values for 🎶.defaultValue match for array
+PASS Values for 🎶.minValue match for array
+PASS Values for 🎶.maxValue match for array
+PASS Values for 🎶.automationRate match for array
 PASS Creating an AudioWorkletNode with a generator for
                     parameter descriptor worked
-FAIL Map match in size for generator assert_equals: expected 3 but got 0
-FAIL Attempting to create an AudioWorkletNode with an non
-              iterable for parameter descriptor should not work assert_throws_dom: function "function () {
-              new AudioWorkletNode(ac, "invalid");
-            }" did not throw
+PASS Map match in size for generator
+PASS generator: 你好 exists in both maps
+PASS Values for 你好.defaultValue match for generator
+PASS Values for 你好.minValue match for generator
+PASS Values for 你好.maxValue match for generator
+PASS Values for 你好.automationRate match for generator
+PASS generator: a control-rate parameter exists in both maps
+PASS Values for a control-rate parameter.defaultValue match for generator
+PASS Values for a control-rate parameter.minValue match for generator
+PASS Values for a control-rate parameter.maxValue match for generator
+PASS Values for a control-rate parameter.automationRate match for generator
+PASS generator: 🎶 exists in both maps
+PASS Values for 🎶.defaultValue match for generator
+PASS Values for 🎶.minValue match for generator
+PASS Values for 🎶.maxValue match for generator
+PASS Values for 🎶.automationRate match for generator
+PASS Attempting to create an AudioWorkletNode with an non
+              iterable for parameter descriptor should not work
 PASS Attempting to create an AudioWorkletNode from a processor
             that does not have a parameterDescriptors getter should work
-FAIL Attempting to create an AudioWorkletNode with two parameter
-            descriptor with the same name should not work assert_throws_dom: function "function () {
-            new AudioWorkletNode(ac, "duplicate-param-name");
-          }" did not throw
+PASS Attempting to create an AudioWorkletNode with two parameter
+            descriptor with the same name should not work
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworklet-audioparam-size.https-expected.txt (268102 => 268103)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworklet-audioparam-size.https-expected.txt	2020-10-07 00:23:27 UTC (rev 268102)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworklet-audioparam-size.https-expected.txt	2020-10-07 00:36:21 UTC (rev 268103)
@@ -1,14 +1,41 @@
-CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: undefined is not an object (evaluating 'nodeParam.setValueAtTime')
 
-Harness Error (FAIL), message = Unhandled rejection: undefined is not an object (evaluating 'nodeParam.setValueAtTime')
-
 PASS # AUDIT TASK RUNNER STARTED.
 PASS Executing "Initializing AudioWorklet and Context"
-TIMEOUT Executing "Verify Size of AudioParam Arrays" Test timed out
-NOTRUN Audit report
+PASS Executing "Verify Size of AudioParam Arrays"
+PASS Audit report
 PASS > [Initializing AudioWorklet and Context]
 PASS   Creating offline context for testing did not throw an exception.
 PASS   Creating test worklet resolved correctly.
 PASS < [Initializing AudioWorklet and Context] All assertions passed. (total 2 assertions)
 PASS > [Verify Size of AudioParam Arrays]
+FAIL X Render quantum 0: array size: Expected 1 for all values but found 128 unexpected values:
+	Index	Actual
+	[0]	0
+	[1]	0
+	[2]	0
+	[3]	0
+	...and 124 more errors. assert_true: expected true got false
+FAIL X Render quantum 1: array size: Expected 1 for all values but found 128 unexpected values:
+	Index	Actual
+	[0]	0
+	[1]	0
+	[2]	0
+	[3]	0
+	...and 124 more errors. assert_true: expected true got false
+FAIL X Render quantum 2-3: array size: Expected 128 for all values but found 256 unexpected values:
+	Index	Actual
+	[0]	0
+	[1]	0
+	[2]	0
+	[3]	0
+	...and 252 more errors. assert_true: expected true got false
+FAIL X Remaining renders: array size: Expected 1 for all values but found 768 unexpected values:
+	Index	Actual
+	[0]	0
+	[1]	0
+	[2]	0
+	[3]	0
+	...and 764 more errors. assert_true: expected true got false
+FAIL < [Verify Size of AudioParam Arrays] 4 out of 4 assertions were failed. assert_true: expected true got false
+FAIL # AUDIT TASK RUNNER FINISHED: 1 out of 2 tasks were failed. assert_true: expected true got false
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworklet-audioparam.https-expected.txt (268102 => 268103)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworklet-audioparam.https-expected.txt	2020-10-07 00:23:27 UTC (rev 268102)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworklet-audioparam.https-expected.txt	2020-10-07 00:36:21 UTC (rev 268103)
@@ -1,10 +1,20 @@
 
 PASS # AUDIT TASK RUNNER STARTED.
 PASS Executing "Initializing AudioWorklet and Context"
-FAIL Executing "Verifying AudioParam in AudioWorkletNode" promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'gainWorkletParam.value')"
+PASS Executing "Verifying AudioParam in AudioWorkletNode"
 PASS Audit report
 PASS > [Initializing AudioWorklet and Context]
 PASS < [Initializing AudioWorklet and Context] All assertions passed. (total 0 assertions)
 PASS > [Verifying AudioParam in AudioWorkletNode]
-PASS # AUDIT TASK RUNNER FINISHED: 2 tasks ran successfully.
+PASS   Default gain value of gainWorkletNode is equal to 0.7070000171661377.
+PASS   Value of gainWorkletParam after setter = 0.1 is equal to 0.10000000149011612.
+FAIL X The rendered buffer: Expected 0 for all values but found 28798 unexpected values:
+	Index	Actual
+	[1]	-0.00020833333837799728
+	[2]	-0.00041666667675599456
+	[3]	-0.0006249999860301614
+	[4]	-0.0008333333535119891
+	...and 28794 more errors. assert_true: expected true got false
+FAIL < [Verifying AudioParam in AudioWorkletNode] 1 out of 3 assertions were failed. assert_true: expected true got false
+FAIL # AUDIT TASK RUNNER FINISHED: 1 out of 2 tasks were failed. assert_true: expected true got false
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletglobalscope-sample-rate.https-expected.txt (268102 => 268103)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletglobalscope-sample-rate.https-expected.txt	2020-10-07 00:23:27 UTC (rev 268102)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletglobalscope-sample-rate.https-expected.txt	2020-10-07 00:36:21 UTC (rev 268103)
@@ -1,7 +1,9 @@
 
 PASS # AUDIT TASK RUNNER STARTED.
-FAIL Executing "Query |sampleRate| upon AudioWorkletGlobalScope construction" promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'frequencyParam.maxValue')"
+PASS Executing "Query |sampleRate| upon AudioWorkletGlobalScope construction"
 PASS Audit report
 PASS > [Query |sampleRate| upon AudioWorkletGlobalScope construction]
+PASS   frequencyParam.maxValue is equal to 24000.
+PASS < [Query |sampleRate| upon AudioWorkletGlobalScope construction] All assertions passed. (total 1 assertions)
 PASS # AUDIT TASK RUNNER FINISHED: 1 tasks ran successfully.
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-channel-count.https-expected.txt (268102 => 268103)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-channel-count.https-expected.txt	2020-10-07 00:23:27 UTC (rev 268102)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-channel-count.https-expected.txt	2020-10-07 00:36:21 UTC (rev 268103)
@@ -1,10 +1,35 @@
-CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: undefined is not an object (evaluating 'gainWorkletNode.parameters.get('gain').value = 1.0')
 
-Harness Error (FAIL), message = Unhandled rejection: undefined is not an object (evaluating 'gainWorkletNode.parameters.get('gain').value = 1.0')
-
 PASS # AUDIT TASK RUNNER STARTED.
-TIMEOUT Executing "setup-buffer-and-worklet" Test timed out
-NOTRUN Executing "verify-rendered-buffer"
-NOTRUN Audit report
+PASS Executing "setup-buffer-and-worklet"
+PASS Executing "verify-rendered-buffer"
+PASS Audit report
 PASS > [setup-buffer-and-worklet]
+PASS < [setup-buffer-and-worklet] All assertions passed. (total 0 assertions)
+PASS > [verify-rendered-buffer]
+PASS   First half of Channel #0 contains only the constant 0.
+FAIL X Second half of Channel #0: Expected 1 for all values but found 128 unexpected values:
+	Index	Actual
+	[0]	0
+	[1]	0
+	[2]	0
+	[3]	0
+	...and 124 more errors. assert_true: expected true got false
+PASS   First half of Channel #1 contains only the constant 0.
+FAIL X Second half of Channel #1: Expected 2 for all values but found 128 unexpected values:
+	Index	Actual
+	[0]	0
+	[1]	0
+	[2]	0
+	[3]	0
+	...and 124 more errors. assert_true: expected true got false
+PASS   First half of Channel #2 contains only the constant 0.
+FAIL X Second half of Channel #2: Expected 3 for all values but found 128 unexpected values:
+	Index	Actual
+	[0]	0
+	[1]	0
+	[2]	0
+	[3]	0
+	...and 124 more errors. assert_true: expected true got false
+FAIL < [verify-rendered-buffer] 3 out of 6 assertions were failed. assert_true: expected true got false
+FAIL # AUDIT TASK RUNNER FINISHED: 1 out of 2 tasks were failed. assert_true: expected true got false
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-construction.https-expected.txt (268102 => 268103)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-construction.https-expected.txt	2020-10-07 00:23:27 UTC (rev 268102)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-construction.https-expected.txt	2020-10-07 00:36:21 UTC (rev 268103)
@@ -4,11 +4,11 @@
 PASS Executing "construction-after-module-loading"
 PASS Audit report
 PASS > [construction-before-module-loading]
-FAIL X Creating a node before loading a module should throw. did not throw an exception. assert_true: expected true got false
-FAIL < [construction-before-module-loading] 1 out of 1 assertions were failed. assert_true: expected true got false
+PASS   Creating a node before loading a module should throw. threw InvalidStateError: "No ScriptProcessor was registered with this name".
+PASS < [construction-before-module-loading] All assertions passed. (total 1 assertions)
 PASS > [construction-after-module-loading]
 PASS   "dummyWorkletNode" is an instance of AudioWorkletNode is true.
-FAIL X Unregistered name "foobar" must throw an exception. did not throw an exception. assert_true: expected true got false
-FAIL < [construction-after-module-loading] 1 out of 2 assertions were failed. assert_true: expected true got false
-FAIL # AUDIT TASK RUNNER FINISHED: 2 out of 2 tasks were failed. assert_true: expected true got false
+PASS   Unregistered name "foobar" must throw an exception. threw InvalidStateError: "No ScriptProcessor was registered with this name".
+PASS < [construction-after-module-loading] All assertions passed. (total 2 assertions)
+PASS # AUDIT TASK RUNNER FINISHED: 2 tasks ran successfully.
 

Modified: trunk/Source/WebCore/CMakeLists.txt (268102 => 268103)


--- trunk/Source/WebCore/CMakeLists.txt	2020-10-07 00:23:27 UTC (rev 268102)
+++ trunk/Source/WebCore/CMakeLists.txt	2020-10-07 00:36:21 UTC (rev 268103)
@@ -475,6 +475,7 @@
     Modules/webaudio/AudioNode.idl
     Modules/webaudio/AudioNodeOptions.idl
     Modules/webaudio/AudioParam.idl
+    Modules/webaudio/AudioParamDescriptor.idl
     Modules/webaudio/AudioParamMap.idl
     Modules/webaudio/AudioProcessingEvent.idl
     Modules/webaudio/AudioProcessingEventInit.idl
@@ -486,6 +487,7 @@
     Modules/webaudio/AudioWorkletNodeOptions.idl
     Modules/webaudio/AudioWorkletProcessor.idl
     Modules/webaudio/AudioWorkletProcessorConstructor.idl
+    Modules/webaudio/AutomationRate.idl
     Modules/webaudio/BaseAudioContext.idl
     Modules/webaudio/BiquadFilterNode.idl
     Modules/webaudio/BiquadFilterOptions.idl

Modified: trunk/Source/WebCore/ChangeLog (268102 => 268103)


--- trunk/Source/WebCore/ChangeLog	2020-10-07 00:23:27 UTC (rev 268102)
+++ trunk/Source/WebCore/ChangeLog	2020-10-07 00:36:21 UTC (rev 268103)
@@ -1,3 +1,58 @@
+2020-10-06  Chris Dumez  <cdu...@apple.com>
+
+        Add implementation for AudioWorkletGlobalScope.registerProcessor()
+        https://bugs.webkit.org/show_bug.cgi?id=217405
+
+        Reviewed by Geoff Garen.
+
+        Add implementation for AudioWorkletGlobalScope.registerProcessor() that matches very closely
+        the specification at:
+        - https://www.w3.org/TR/webaudio/#dom-audioworkletglobalscope-registerprocessor
+
+        Also update the AudioWorkletNode constructor implementation as per:
+        - https://www.w3.org/TR/webaudio/#AudioWorkletNode-constructors
+
+        Now that the AudioWorklet is able to register a processor and AudioParamDescriptors, the
+        AudioWorkletNode constructor is able to make sure that a processor with the given name was
+        indeed registered. We are also able to construct the AudioParam objects based on the
+        AudioParamDescriptors provided when registering the processor.
+
+        Note that even though it is now possible to register an AudioWorkletProcessor, it is still
+        not used to process the audio. An AudioWorkletNode currently only outputs silence. This will
+        be addresssed in a future patch.
+
+        No new tests, rebaselined existing tests.
+
+        * CMakeLists.txt:
+        * DerivedSources-input.xcfilelist:
+        * DerivedSources-output.xcfilelist:
+        * DerivedSources.make:
+        * Modules/webaudio/AudioParam.h:
+        * Modules/webaudio/AudioParam.idl:
+        * Modules/webaudio/AudioParamDescriptor.h: Copied from Source/WebCore/Modules/webaudio/AudioWorkletGlobalScope.idl.
+        (WebCore::AudioParamDescriptor::isolatedCopy const):
+        * Modules/webaudio/AudioParamDescriptor.idl: Copied from Source/WebCore/Modules/webaudio/AudioWorkletGlobalScope.idl.
+        * Modules/webaudio/AudioWorkletGlobalScope.cpp:
+        (WebCore::AudioWorkletGlobalScope::registerProcessor):
+        * Modules/webaudio/AudioWorkletGlobalScope.h:
+        * Modules/webaudio/AudioWorkletGlobalScope.idl:
+        * Modules/webaudio/AudioWorkletMessagingProxy.cpp:
+        (WebCore::AudioWorkletMessagingProxy::AudioWorkletMessagingProxy):
+        (WebCore::AudioWorkletMessagingProxy::postTaskToAudioWorklet):
+        * Modules/webaudio/AudioWorkletMessagingProxy.h:
+        * Modules/webaudio/AudioWorkletNode.cpp:
+        (WebCore::AudioWorkletNode::create):
+        * Modules/webaudio/AudioWorkletThread.h:
+        (WebCore::AudioWorkletThread::messagingProxy):
+        * Modules/webaudio/AutomationRate.h: Copied from Source/WebCore/Modules/webaudio/AudioWorkletGlobalScope.idl.
+        * Modules/webaudio/AutomationRate.idl: Copied from Source/WebCore/Modules/webaudio/AudioWorkletGlobalScope.idl.
+        * Modules/webaudio/BaseAudioContext.cpp:
+        (WebCore::BaseAudioContext::addAudioParamDescriptors):
+        * Modules/webaudio/BaseAudioContext.h:
+        (WebCore::BaseAudioContext::parameterDescriptorMap const):
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+
 2020-10-06  Zalan Bujtas  <za...@apple.com>
 
         [LFC] FormattingContext::Geometry::contentHeightForFormattingContextRoot should take a const ContainerBox&

Modified: trunk/Source/WebCore/DerivedSources-input.xcfilelist (268102 => 268103)


--- trunk/Source/WebCore/DerivedSources-input.xcfilelist	2020-10-07 00:23:27 UTC (rev 268102)
+++ trunk/Source/WebCore/DerivedSources-input.xcfilelist	2020-10-07 00:36:21 UTC (rev 268103)
@@ -329,6 +329,7 @@
 $(PROJECT_DIR)/Modules/webaudio/AudioNode.idl
 $(PROJECT_DIR)/Modules/webaudio/AudioNodeOptions.idl
 $(PROJECT_DIR)/Modules/webaudio/AudioParam.idl
+$(PROJECT_DIR)/Modules/webaudio/AudioParamDescriptor.idl
 $(PROJECT_DIR)/Modules/webaudio/AudioParamMap.idl
 $(PROJECT_DIR)/Modules/webaudio/AudioProcessingEvent.idl
 $(PROJECT_DIR)/Modules/webaudio/AudioProcessingEventInit.idl
@@ -340,6 +341,7 @@
 $(PROJECT_DIR)/Modules/webaudio/AudioWorkletNodeOptions.idl
 $(PROJECT_DIR)/Modules/webaudio/AudioWorkletProcessor.idl
 $(PROJECT_DIR)/Modules/webaudio/AudioWorkletProcessorConstructor.idl
+$(PROJECT_DIR)/Modules/webaudio/AutomationRate.idl
 $(PROJECT_DIR)/Modules/webaudio/BaseAudioContext.idl
 $(PROJECT_DIR)/Modules/webaudio/BiquadFilterNode.idl
 $(PROJECT_DIR)/Modules/webaudio/BiquadFilterOptions.idl

Modified: trunk/Source/WebCore/DerivedSources-output.xcfilelist (268102 => 268103)


--- trunk/Source/WebCore/DerivedSources-output.xcfilelist	2020-10-07 00:23:27 UTC (rev 268102)
+++ trunk/Source/WebCore/DerivedSources-output.xcfilelist	2020-10-07 00:36:21 UTC (rev 268103)
@@ -188,6 +188,8 @@
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAudioNodeOptions.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAudioParam.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAudioParam.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAudioParamDescriptor.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAudioParamDescriptor.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAudioParamMap.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAudioParamMap.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAudioProcessingEvent.cpp
@@ -230,6 +232,8 @@
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAuthenticatorResponse.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAuthenticatorTransport.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAuthenticatorTransport.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAutomationRate.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAutomationRate.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSBarProp.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSBarProp.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSBaseAudioContext.cpp

Modified: trunk/Source/WebCore/DerivedSources.make (268102 => 268103)


--- trunk/Source/WebCore/DerivedSources.make	2020-10-07 00:23:27 UTC (rev 268102)
+++ trunk/Source/WebCore/DerivedSources.make	2020-10-07 00:36:21 UTC (rev 268103)
@@ -407,6 +407,7 @@
     $(WebCore)/Modules/webaudio/AudioNode.idl \
     $(WebCore)/Modules/webaudio/AudioNodeOptions.idl \
     $(WebCore)/Modules/webaudio/AudioParam.idl \
+    $(WebCore)/Modules/webaudio/AudioParamDescriptor.idl \
     $(WebCore)/Modules/webaudio/AudioParamMap.idl \
     $(WebCore)/Modules/webaudio/AudioProcessingEvent.idl \
     $(WebCore)/Modules/webaudio/AudioProcessingEventInit.idl \
@@ -418,6 +419,7 @@
     $(WebCore)/Modules/webaudio/AudioWorkletNodeOptions.idl \
     $(WebCore)/Modules/webaudio/AudioWorkletProcessor.idl \
     $(WebCore)/Modules/webaudio/AudioWorkletProcessorConstructor.idl \
+    $(WebCore)/Modules/webaudio/AutomationRate.idl \
     $(WebCore)/Modules/webaudio/BaseAudioContext.idl \
     $(WebCore)/Modules/webaudio/BiquadFilterNode.idl \
     $(WebCore)/Modules/webaudio/BiquadFilterOptions.idl \

Modified: trunk/Source/WebCore/Modules/webaudio/AudioParam.h (268102 => 268103)


--- trunk/Source/WebCore/Modules/webaudio/AudioParam.h	2020-10-07 00:23:27 UTC (rev 268102)
+++ trunk/Source/WebCore/Modules/webaudio/AudioParam.h	2020-10-07 00:36:21 UTC (rev 268103)
@@ -31,6 +31,7 @@
 #include "AudioContext.h"
 #include "AudioParamTimeline.h"
 #include "AudioSummingJunction.h"
+#include "AutomationRate.h"
 #include "WebKitAudioContext.h"
 #include <_javascript_Core/Float32Array.h>
 #include <sys/types.h>
@@ -42,7 +43,6 @@
 
 class AudioNodeOutput;
 
-enum class AutomationRate : bool { ARate, KRate };
 enum class AutomationRateMode : bool { Fixed, Variable };
 
 class AudioParam final

Modified: trunk/Source/WebCore/Modules/webaudio/AudioParam.idl (268102 => 268103)


--- trunk/Source/WebCore/Modules/webaudio/AudioParam.idl	2020-10-07 00:23:27 UTC (rev 268102)
+++ trunk/Source/WebCore/Modules/webaudio/AudioParam.idl	2020-10-07 00:36:21 UTC (rev 268103)
@@ -28,14 +28,6 @@
 
 [
     Conditional=WEB_AUDIO,
-    ImplementedAs=AutomationRate
-] enum AutomationRate {
-    "a-rate",
-    "k-rate"
-};
-
-[
-    Conditional=WEB_AUDIO,
     Exposed=Window
 ] interface AudioParam {
     [ImplementedAs=valueForBindings] attribute float value;

Copied: trunk/Source/WebCore/Modules/webaudio/AudioParamDescriptor.h (from rev 268099, trunk/Source/WebCore/Modules/webaudio/AudioWorkletGlobalScope.idl) (0 => 268103)


--- trunk/Source/WebCore/Modules/webaudio/AudioParamDescriptor.h	                        (rev 0)
+++ trunk/Source/WebCore/Modules/webaudio/AudioParamDescriptor.h	2020-10-07 00:36:21 UTC (rev 268103)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEB_AUDIO)
+
+#include "AutomationRate.h"
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+struct AudioParamDescriptor {
+    String name;
+    float defaultValue { 0 };
+    float minValue { -3.4028235e38 };
+    float maxValue { 3.4028235e38 };
+    AutomationRate automationRate { AutomationRate::ARate };
+
+    AudioParamDescriptor isolatedCopy() const
+    {
+        return {
+            name.isolatedCopy(),
+            defaultValue,
+            minValue,
+            maxValue,
+            automationRate
+        };
+    }
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_AUDIO)

Copied: trunk/Source/WebCore/Modules/webaudio/AudioParamDescriptor.idl (from rev 268099, trunk/Source/WebCore/Modules/webaudio/AudioWorkletGlobalScope.idl) (0 => 268103)


--- trunk/Source/WebCore/Modules/webaudio/AudioParamDescriptor.idl	                        (rev 0)
+++ trunk/Source/WebCore/Modules/webaudio/AudioParamDescriptor.idl	2020-10-07 00:36:21 UTC (rev 268103)
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+[
+    Conditional=WEB_AUDIO
+] dictionary AudioParamDescriptor {
+    required DOMString name;
+    float defaultValue = 0;
+    float minValue = -3.4028235e38;
+    float maxValue = 3.4028235e38;
+    AutomationRate automationRate = "a-rate";
+};

Modified: trunk/Source/WebCore/Modules/webaudio/AudioWorkletGlobalScope.cpp (268102 => 268103)


--- trunk/Source/WebCore/Modules/webaudio/AudioWorkletGlobalScope.cpp	2020-10-07 00:23:27 UTC (rev 268102)
+++ trunk/Source/WebCore/Modules/webaudio/AudioWorkletGlobalScope.cpp	2020-10-07 00:36:21 UTC (rev 268103)
@@ -31,7 +31,12 @@
 #if ENABLE(WEB_AUDIO)
 #include "AudioWorkletGlobalScope.h"
 
-#include "AudioWorkletProcessorConstructor.h"
+#include "AudioParamDescriptor.h"
+#include "AudioWorklet.h"
+#include "AudioWorkletMessagingProxy.h"
+#include "JSAudioWorkletProcessorConstructor.h"
+#include "JSDOMConvert.h"
+#include <wtf/CrossThreadCopier.h>
 #include <wtf/IsoMallocInlines.h>
 
 namespace WebCore {
@@ -48,10 +53,60 @@
 
 AudioWorkletGlobalScope::~AudioWorkletGlobalScope() = default;
 
-void AudioWorkletGlobalScope::registerProcessor(String&& name, Ref<AudioWorkletProcessorConstructor>&&)
+// https://www.w3.org/TR/webaudio/#dom-audioworkletglobalscope-registerprocessor
+ExceptionOr<void> AudioWorkletGlobalScope::registerProcessor(String&& name, Ref<JSAudioWorkletProcessorConstructor>&& processorContructor)
 {
-    // FIXME: Implement this.
-    UNUSED_PARAM(name);
+    ASSERT(!isMainThread());
+
+    if (name.isEmpty())
+        return Exception { NotSupportedError, "Name cannot be the empty string"_s };
+
+    if (m_processorConstructorMap.contains(name))
+        return Exception { NotSupportedError, "A processor was already registered with this name"_s };
+
+    JSC::JSObject* jsConstructor = processorContructor->callbackData()->callback();
+    auto* globalObject = jsConstructor->globalObject();
+    auto& vm = globalObject->vm();
+    auto scope = DECLARE_THROW_SCOPE(vm);
+
+    if (!jsConstructor->isConstructor(vm))
+        return Exception { TypeError, "Class definitition passed to registerProcessor() is not a constructor"_s };
+
+    auto prototype = jsConstructor->getPrototype(vm, globalObject);
+    RETURN_IF_EXCEPTION(scope, Exception { TypeError });
+
+    if (!prototype.isObject())
+        return Exception { TypeError, "Class definitition passed to registerProcessor() has invalid prototype"_s };
+
+    auto parameterDescriptorsValue = jsConstructor->get(globalObject, JSC::Identifier::fromString(vm, "parameterDescriptors"));
+    RETURN_IF_EXCEPTION(scope, Exception { TypeError });
+
+    Vector<AudioParamDescriptor> parameterDescriptors;
+    if (!parameterDescriptorsValue.isUndefined()) {
+        parameterDescriptors = convert<IDLSequence<IDLDictionary<AudioParamDescriptor>>>(*globalObject, parameterDescriptorsValue);
+        RETURN_IF_EXCEPTION(scope, Exception { TypeError });
+        UNUSED_PARAM(parameterDescriptors);
+        HashSet<String> paramNames;
+        for (auto& descriptor : parameterDescriptors) {
+            auto addResult = paramNames.add(descriptor.name);
+            if (!addResult.isNewEntry)
+                return Exception { NotSupportedError, makeString("parameterDescriptors contain duplicate AudioParam name: ", name) };
+            if (descriptor.defaultValue < descriptor.minValue)
+                return Exception { InvalidStateError, makeString("AudioParamDescriptor with name '", name, "' has a defaultValue that is less than the minValue") };
+            if (descriptor.defaultValue > descriptor.maxValue)
+                return Exception { InvalidStateError, makeString("AudioParamDescriptor with name '", name, "' has a defaultValue that is greater than the maxValue") };
+        }
+    }
+
+    m_processorConstructorMap.add(name, WTFMove(processorContructor));
+
+    thread().messagingProxy().postTaskToAudioWorklet([name = name.isolatedCopy(), parameterDescriptors = crossThreadCopy(parameterDescriptors)](AudioWorklet& worklet) mutable {
+        ASSERT(isMainThread());
+        if (auto* audioContext = worklet.audioContext())
+            audioContext->addAudioParamDescriptors(name, WTFMove(parameterDescriptors));
+    });
+
+    return { };
 }
 
 void AudioWorkletGlobalScope::prepareForTermination()

Modified: trunk/Source/WebCore/Modules/webaudio/AudioWorkletGlobalScope.h (268102 => 268103)


--- trunk/Source/WebCore/Modules/webaudio/AudioWorkletGlobalScope.h	2020-10-07 00:23:27 UTC (rev 268102)
+++ trunk/Source/WebCore/Modules/webaudio/AudioWorkletGlobalScope.h	2020-10-07 00:36:21 UTC (rev 268103)
@@ -34,8 +34,8 @@
 
 namespace WebCore {
 
-class AudioWorkletProcessorConstructor;
 class AudioWorkletThread;
+class JSAudioWorkletProcessorConstructor;
 
 struct WorkletParameters;
 
@@ -48,7 +48,7 @@
     }
     ~AudioWorkletGlobalScope();
 
-    void registerProcessor(String&& name, Ref<AudioWorkletProcessorConstructor>&&);
+    ExceptionOr<void> registerProcessor(String&& name, Ref<JSAudioWorkletProcessorConstructor>&&);
 
     void setCurrentFrame(float currentFrame) { m_currentFrame = currentFrame; }
     size_t currentFrame() const { return m_currentFrame; }
@@ -71,6 +71,7 @@
     Ref<AudioWorkletThread> m_thread;
     size_t m_currentFrame { 0 };
     const float m_sampleRate;
+    HashMap<String, RefPtr<JSAudioWorkletProcessorConstructor>> m_processorConstructorMap;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/Modules/webaudio/AudioWorkletGlobalScope.idl (268102 => 268103)


--- trunk/Source/WebCore/Modules/webaudio/AudioWorkletGlobalScope.idl	2020-10-07 00:23:27 UTC (rev 268102)
+++ trunk/Source/WebCore/Modules/webaudio/AudioWorkletGlobalScope.idl	2020-10-07 00:36:21 UTC (rev 268103)
@@ -35,7 +35,7 @@
     IsImmutablePrototypeExoticObjectOnPrototype,
     Global=(Worklet,AudioWorklet),
 ] interface AudioWorkletGlobalScope : WorkletGlobalScope {
-    undefined registerProcessor(DOMString name, AudioWorkletProcessorConstructor processorCtor);
+    [MayThrowException] undefined registerProcessor(DOMString name, AudioWorkletProcessorConstructor processorCtor);
     readonly attribute unsigned long long currentFrame;
     readonly attribute double currentTime;
     readonly attribute float sampleRate;

Modified: trunk/Source/WebCore/Modules/webaudio/AudioWorkletMessagingProxy.cpp (268102 => 268103)


--- trunk/Source/WebCore/Modules/webaudio/AudioWorkletMessagingProxy.cpp	2020-10-07 00:23:27 UTC (rev 268102)
+++ trunk/Source/WebCore/Modules/webaudio/AudioWorkletMessagingProxy.cpp	2020-10-07 00:36:21 UTC (rev 268103)
@@ -56,7 +56,8 @@
 }
 
 AudioWorkletMessagingProxy::AudioWorkletMessagingProxy(AudioWorklet& worklet)
-    : m_document(*worklet.document())
+    : m_worklet(makeWeakPtr(worklet))
+    , m_document(*worklet.document())
     , m_workletThread(AudioWorkletThread::create(*this, generateWorkletParameters(worklet)))
 {
     ASSERT(isMainThread());
@@ -91,6 +92,14 @@
     return postTaskForModeToWorkletGlobalScope(WTFMove(task), mode);
 }
 
+void AudioWorkletMessagingProxy::postTaskToAudioWorklet(Function<void(AudioWorklet&)>&& task)
+{
+    m_document->postTask([this, protectedThis = makeRef(*this), task = WTFMove(task)](ScriptExecutionContext&) {
+        if (m_worklet)
+            task(*m_worklet);
+    });
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(WEB_AUDIO)

Modified: trunk/Source/WebCore/Modules/webaudio/AudioWorkletMessagingProxy.h (268102 => 268103)


--- trunk/Source/WebCore/Modules/webaudio/AudioWorkletMessagingProxy.h	2020-10-07 00:23:27 UTC (rev 268102)
+++ trunk/Source/WebCore/Modules/webaudio/AudioWorkletMessagingProxy.h	2020-10-07 00:36:21 UTC (rev 268103)
@@ -52,6 +52,8 @@
 
     AudioWorkletThread& workletThread() { return m_workletThread.get(); }
 
+    void postTaskToAudioWorklet(Function<void(AudioWorklet&)>&&);
+
 private:
     explicit AudioWorkletMessagingProxy(AudioWorklet&);
 
@@ -62,6 +64,7 @@
 
     bool isAudioWorkletMessagingProxy() const final { return true; }
 
+    WeakPtr<AudioWorklet> m_worklet;
     Ref<Document> m_document;
     Ref<AudioWorkletThread> m_workletThread;
 };

Modified: trunk/Source/WebCore/Modules/webaudio/AudioWorkletNode.cpp (268102 => 268103)


--- trunk/Source/WebCore/Modules/webaudio/AudioWorkletNode.cpp	2020-10-07 00:23:27 UTC (rev 268102)
+++ trunk/Source/WebCore/Modules/webaudio/AudioWorkletNode.cpp	2020-10-07 00:36:21 UTC (rev 268103)
@@ -33,6 +33,7 @@
 
 #include "AudioContext.h"
 #include "AudioNodeOutput.h"
+#include "AudioParam.h"
 #include "AudioParamMap.h"
 #include "AudioWorkletNodeOptions.h"
 #include "BaseAudioContext.h"
@@ -59,7 +60,10 @@
         }
     }
 
-    // FIXME: Throw an InvalidStateError if |name| is already present in the context's node name to parameter descriptor map.
+    auto it = context.parameterDescriptorMap().find(name);
+    if (it == context.parameterDescriptorMap().end())
+        return Exception { InvalidStateError, "No ScriptProcessor was registered with this name"_s };
+    auto& parameterDescriptors = it->value;
 
     if (context.isClosed() || !context.scriptExecutionContext())
         return Exception { InvalidStateError, "Context is closed"_s };
@@ -67,6 +71,7 @@
     auto messageChannel = MessageChannel::create(*context.scriptExecutionContext());
     // FIXME: Pass messageChannel's port2 to the AudioWorkletProcessor.
 
+    auto parameterData = WTFMove(options.parameterData);
     auto node = adoptRef(*new AudioWorkletNode(context, WTFMove(name), WTFMove(options), *messageChannel->port1()));
 
     auto result = node->handleAudioNodeOptions(options, { 2, ChannelCountMode::Max, ChannelInterpretation::Speakers });
@@ -73,6 +78,18 @@
     if (result.hasException())
         return result.releaseException();
 
+    for (auto& descriptor : parameterDescriptors) {
+        auto parameter = AudioParam::create(context, descriptor.name, descriptor.defaultValue, descriptor.minValue, descriptor.maxValue, descriptor.automationRate);
+        node->parameters().add(descriptor.name, WTFMove(parameter));
+    }
+
+    if (parameterData) {
+        for (auto& parameter : *parameterData) {
+            if (auto* audioParam = node->parameters().map().get(parameter.key))
+                audioParam->setValue(parameter.value);
+        }
+    }
+
     return node;
 }
 

Modified: trunk/Source/WebCore/Modules/webaudio/AudioWorkletThread.h (268102 => 268103)


--- trunk/Source/WebCore/Modules/webaudio/AudioWorkletThread.h	2020-10-07 00:23:27 UTC (rev 268102)
+++ trunk/Source/WebCore/Modules/webaudio/AudioWorkletThread.h	2020-10-07 00:36:21 UTC (rev 268103)
@@ -59,6 +59,7 @@
     WorkerRunLoop& runLoop() final { return m_runLoop; }
     WorkerLoaderProxy& workerLoaderProxy() final;
     Thread* thread() const final { return m_thread.get(); }
+    AudioWorkletMessagingProxy& messagingProxy() { return m_messagingProxy; }
 
 private:
     AudioWorkletThread(AudioWorkletMessagingProxy&, const WorkletParameters&);

Copied: trunk/Source/WebCore/Modules/webaudio/AutomationRate.h (from rev 268099, trunk/Source/WebCore/Modules/webaudio/AudioWorkletGlobalScope.idl) (0 => 268103)


--- trunk/Source/WebCore/Modules/webaudio/AutomationRate.h	                        (rev 0)
+++ trunk/Source/WebCore/Modules/webaudio/AutomationRate.h	2020-10-07 00:36:21 UTC (rev 268103)
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEB_AUDIO)
+
+namespace WebCore {
+
+enum class AutomationRate : bool { ARate, KRate };
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_AUDIO)

Copied: trunk/Source/WebCore/Modules/webaudio/AutomationRate.idl (from rev 268099, trunk/Source/WebCore/Modules/webaudio/AudioWorkletGlobalScope.idl) (0 => 268103)


--- trunk/Source/WebCore/Modules/webaudio/AutomationRate.idl	                        (rev 0)
+++ trunk/Source/WebCore/Modules/webaudio/AutomationRate.idl	2020-10-07 00:36:21 UTC (rev 268103)
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+    Conditional=WEB_AUDIO,
+] enum AutomationRate {
+    "a-rate",
+    "k-rate"
+};

Modified: trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.cpp (268102 => 268103)


--- trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.cpp	2020-10-07 00:23:27 UTC (rev 268102)
+++ trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.cpp	2020-10-07 00:36:21 UTC (rev 268103)
@@ -39,6 +39,7 @@
 #include "AudioListener.h"
 #include "AudioNodeInput.h"
 #include "AudioNodeOutput.h"
+#include "AudioParamDescriptor.h"
 #include "AudioSession.h"
 #include "AudioWorklet.h"
 #include "BiquadFilterNode.h"
@@ -1339,6 +1340,12 @@
     RELEASE_ASSERT_NOT_REACHED();
 }
 
+void BaseAudioContext::addAudioParamDescriptors(const String& processorName, Vector<AudioParamDescriptor>&& descriptors)
+{
+    ASSERT(!m_parameterDescriptorMap.contains(processorName));
+    m_parameterDescriptorMap.add(processorName, WTFMove(descriptors));
+}
+
 #if !RELEASE_LOG_DISABLED
 WTFLogChannel& BaseAudioContext::logChannel() const
 {

Modified: trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.h (268102 => 268103)


--- trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.h	2020-10-07 00:23:27 UTC (rev 268102)
+++ trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.h	2020-10-07 00:36:21 UTC (rev 268103)
@@ -88,6 +88,8 @@
 class StereoPannerNode;
 class WaveShaperNode;
 
+struct AudioParamDescriptor;
+
 template<typename IDLType> class DOMPromiseDeferred;
 
 // AudioContext is the cornerstone of the web audio API and all AudioNodes are created from it.
@@ -321,6 +323,9 @@
 
     PeriodicWave& periodicWave(OscillatorType);
 
+    void addAudioParamDescriptors(const String& processorName, Vector<AudioParamDescriptor>&&);
+    const HashMap<String, Vector<AudioParamDescriptor>>& parameterDescriptorMap() const { return m_parameterDescriptorMap; }
+
 protected:
     explicit BaseAudioContext(Document&, const AudioContextOptions& = { });
     BaseAudioContext(Document&, unsigned numberOfChannels, RefPtr<AudioBuffer>&& renderTarget);
@@ -469,6 +474,8 @@
 
     AudioIOPosition m_outputPosition;
 
+    HashMap<String, Vector<AudioParamDescriptor>> m_parameterDescriptorMap;
+
     // [[suspended by user]] flag in the specification:
     // https://www.w3.org/TR/webaudio/#dom-audiocontext-suspended-by-user-slot
     bool m_wasSuspendedByScript { false };

Modified: trunk/Source/WebCore/Sources.txt (268102 => 268103)


--- trunk/Source/WebCore/Sources.txt	2020-10-07 00:23:27 UTC (rev 268102)
+++ trunk/Source/WebCore/Sources.txt	2020-10-07 00:36:21 UTC (rev 268103)
@@ -2681,6 +2681,7 @@
 JSAudioNode.cpp
 JSAudioNodeOptions.cpp
 JSAudioParam.cpp
+JSAudioParamDescriptor.cpp
 JSAudioParamMap.cpp
 JSAudioProcessingEvent.cpp
 JSAudioProcessingEventInit.cpp
@@ -2700,6 +2701,7 @@
 JSAuthenticatorAttestationResponse.cpp
 JSAuthenticatorResponse.cpp
 JSAuthenticatorTransport.cpp
+JSAutomationRate.cpp
 JSBarProp.cpp
 JSBaseAudioContext.cpp
 JSBasicCredential.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (268102 => 268103)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-10-07 00:23:27 UTC (rev 268102)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-10-07 00:36:21 UTC (rev 268103)
@@ -2497,6 +2497,8 @@
 		83726EFB252679C500C6114E /* AudioWorkletProcessorConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = 83726EF8252679B200C6114E /* AudioWorkletProcessorConstructor.h */; };
 		8372DB311A6780A800C697C5 /* DiagnosticLoggingResultType.h in Headers */ = {isa = PBXBuildFile; fileRef = 8372DB301A6780A800C697C5 /* DiagnosticLoggingResultType.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		83745D0224D899D300FBDCC4 /* GainOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 83745CFF24D899C200FBDCC4 /* GainOptions.h */; };
+		8375699E252CF36200E1B956 /* AudioParamDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 83756999252CF35E00E1B956 /* AudioParamDescriptor.h */; };
+		8375699F252CF36400E1B956 /* AutomationRate.h in Headers */ = {isa = PBXBuildFile; fileRef = 8375699D252CF35F00E1B956 /* AutomationRate.h */; };
 		83765F951DAC522F00C06537 /* MouseEventInit.h in Headers */ = {isa = PBXBuildFile; fileRef = 83765F941DAC521800C06537 /* MouseEventInit.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		8378878224D8A609000D4A5B /* AudioBufferSourceOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 8378877F24D8A5FC000D4A5B /* AudioBufferSourceOptions.h */; };
 		8379363F1FBBB0B400C8023C /* ServiceWorkerClientData.h in Headers */ = {isa = PBXBuildFile; fileRef = 8379363E1FBBB0A500C8023C /* ServiceWorkerClientData.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -10720,6 +10722,10 @@
 		8372DB301A6780A800C697C5 /* DiagnosticLoggingResultType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DiagnosticLoggingResultType.h; sourceTree = "<group>"; };
 		83745CFF24D899C200FBDCC4 /* GainOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GainOptions.h; sourceTree = "<group>"; };
 		83745D0124D899C200FBDCC4 /* GainOptions.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = GainOptions.idl; sourceTree = "<group>"; };
+		83756999252CF35E00E1B956 /* AudioParamDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AudioParamDescriptor.h; sourceTree = "<group>"; };
+		8375699B252CF35E00E1B956 /* AutomationRate.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = AutomationRate.idl; sourceTree = "<group>"; };
+		8375699C252CF35F00E1B956 /* AudioParamDescriptor.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = AudioParamDescriptor.idl; sourceTree = "<group>"; };
+		8375699D252CF35F00E1B956 /* AutomationRate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AutomationRate.h; sourceTree = "<group>"; };
 		837609C81F54CC13000C122D /* ErrorCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ErrorCallback.cpp; sourceTree = "<group>"; };
 		83765F931DAC521800C06537 /* MouseEventInit.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MouseEventInit.idl; sourceTree = "<group>"; };
 		83765F941DAC521800C06537 /* MouseEventInit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MouseEventInit.h; sourceTree = "<group>"; };
@@ -29974,6 +29980,8 @@
 				FD315FD212B0267500C1A359 /* AudioParam.cpp */,
 				FD315FD312B0267500C1A359 /* AudioParam.h */,
 				FD315FD412B0267500C1A359 /* AudioParam.idl */,
+				83756999252CF35E00E1B956 /* AudioParamDescriptor.h */,
+				8375699C252CF35F00E1B956 /* AudioParamDescriptor.idl */,
 				83B9870225225F0C00A939F1 /* AudioParamMap.cpp */,
 				83B986FF25225F0B00A939F1 /* AudioParamMap.h */,
 				83B9870825225F0E00A939F1 /* AudioParamMap.idl */,
@@ -30011,6 +30019,8 @@
 				83726EFA252679B300C6114E /* AudioWorkletProcessorConstructor.idl */,
 				83FC994A252557E800177618 /* AudioWorkletThread.cpp */,
 				83FC9949252557E700177618 /* AudioWorkletThread.h */,
+				8375699D252CF35F00E1B956 /* AutomationRate.h */,
+				8375699B252CF35E00E1B956 /* AutomationRate.idl */,
 				83198FBB24A160C100420B05 /* BaseAudioContext.cpp */,
 				83198FBE24A160C100420B05 /* BaseAudioContext.h */,
 				83198FBD24A160C100420B05 /* BaseAudioContext.idl */,
@@ -30588,6 +30598,7 @@
 				E71467B324ABAEF200FB2F50 /* AudioNodeOptions.h in Headers */,
 				FD31601812B0267600C1A359 /* AudioNodeOutput.h in Headers */,
 				FD31601D12B0267600C1A359 /* AudioParam.h in Headers */,
+				8375699E252CF36200E1B956 /* AudioParamDescriptor.h in Headers */,
 				83B9870C25225F8300A939F1 /* AudioParamMap.h in Headers */,
 				FD359190138DB22000E1EBEC /* AudioParamTimeline.h in Headers */,
 				FD31602012B0267600C1A359 /* AudioProcessingEvent.h in Headers */,
@@ -30642,6 +30653,7 @@
 				7C1843FE1C8B7283002EB973 /* Autofill.h in Headers */,
 				7C1E97281A9F9834007BF0FB /* AutoFillButtonElement.h in Headers */,
 				5CCC270922D5483A00964FA0 /* AutofillElements.h in Headers */,
+				8375699F252CF36400E1B956 /* AutomationRate.h in Headers */,
 				C9D467051E60C465008195FB /* AutoplayEvent.h in Headers */,
 				45830D4E1679B4F800ACF8C3 /* AutoscrollController.h in Headers */,
 				A8CFF04E0A154F09000A4234 /* AutoTableLayout.h in Headers */,
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to