Bug 1631985 [wpt PR 23158] - Correct input connection and automatic pull behavior of AudioWorkletNode, a=testonly
authorHongchan Choi <hongchan@chromium.org>
Tue, 28 Apr 2020 11:38:48 +0000
changeset 527588 ec6d4d042778ae8d8d00c8b3ddeca04f5dd99824
parent 527587 0b423a6d0e95349c5ff9d424c71c9174fd86203b
child 527589 f187ee9a9bd099a30f16d5a8e8d8836b7afcf83a
push id37368
push userbtara@mozilla.com
push dateFri, 01 May 2020 21:45:51 +0000
treeherdermozilla-central@0f9c5a59e45d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1631985, 23158, 1046516
milestone77.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1631985 [wpt PR 23158] - Correct input connection and automatic pull behavior of AudioWorkletNode, a=testonly Automatic update from web-platform-tests Correct input connection and automatic pull behavior of AudioWorkletNode This CL fixes a failing test (process-parameters.https.html) and it needs two changes in AudioWorkletNode: 1. Handling of unconnected inputs: - spec: https://webaudio.github.io/web-audio-api/#dom-audioworkletprocessor-process-inputs-outputs-parameters-inputs - "If there are no actively processing AudioNodes connected to the ๐‘›th input of the AudioWorkletNode for the current render quantum, then the content of inputs[n] is an empty array, indicating that zero channels of input are available." - Thus, if an input is not connected, it will have an array with zero element. (length == 0) 2. Handling of automatic pull: - The implementation did not have a proper automatic pull functionality for AudioWorkletNode. Without connect() or disconnect() call the node will not be automatically pulled. This change introduces failures in the "active processing" tests, because those tests are expecting non-zero channel count for the unconnected input: - the-audiobuffersourcenode-interface/active-processing.https.html - the-channelmergernode-interface/active-processing.https.html - the-convolvernode-interface/active-processing.https.html I prefer to mark 3 tests above "failure", and handle them later in a separate patch. Bug: 1046516 Test: the-audioworklet-interface/process-parameters.https.html Change-Id: I55f9a1b6eb88c172a8d050598c6e5f946fe9692b -- wpt-commits: e764b34bd01c8ed11efeb9205589dc4dbf09cf54 wpt-pr: 23158
testing/web-platform/tests/webaudio/the-audio-api/the-audioworklet-interface/processors/add-offset.js
testing/web-platform/tests/webaudio/the-audio-api/the-audioworklet-interface/processors/input-length-processor.js
--- a/testing/web-platform/tests/webaudio/the-audio-api/the-audioworklet-interface/processors/add-offset.js
+++ b/testing/web-platform/tests/webaudio/the-audio-api/the-audioworklet-interface/processors/add-offset.js
@@ -6,26 +6,29 @@
  */
 class AddOffsetProcessor extends AudioWorkletProcessor {
   constructor(options) {
     super();
 
     this._offset = options.processorOptions.offset;
   }
 
-  process(inputs, outputs, parameters) {
-    let input = inputs[0][0];
-    let output = outputs[0][0];
+  process(inputs, outputs) {
+    // This processor assumes the node has at least 1 input and 1 output.
+    let input = inputs[0];
+    let output = outputs[0];
+    let outputChannel = output[0];
+
     if (input.length > 0) {
-      for (let k = 0; k < input.length; ++k) {
-        output[k] = input[k] + this._offset;
-      }
+      let inputChannel = input[0];
+      for (let k = 0; k < outputChannel.length; ++k)
+        outputChannel[k] = inputChannel[k] + this._offset;
     } else {
       // No input connected, so pretend it's silence and just fill the
       // output with the offset value.
-      output.fill(this._offset);
+      outputChannel.fill(this._offset);
     }
 
     return true;
   }
 }
 
 registerProcessor('add-offset-processor', AddOffsetProcessor);
--- a/testing/web-platform/tests/webaudio/the-audio-api/the-audioworklet-interface/processors/input-length-processor.js
+++ b/testing/web-platform/tests/webaudio/the-audio-api/the-audioworklet-interface/processors/input-length-processor.js
@@ -11,15 +11,17 @@ class InputLengthProcessor extends Audio
     super();
   }
 
   process(inputs, outputs, parameters) {
     let input = inputs[0];
     let output = outputs[0];
 
     // Set output channel to the length of the input channel array.
-    output[0].fill(input[0].length);
+    // If the input is unconnected, set the value to zero.
+    const fillValue = input.length > 0 ? input[0].length : 0;
+    output[0].fill(fillValue);
 
     return true;
   }
 }
 
 registerProcessor('input-length-processor', InputLengthProcessor);