зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1444102 [wpt PR 9925] - Set array length to 0 for disconnected worklet input, a=testonly
Automatic update from web-platform-testsSet array length to 0 for disconnected worklet input The spec says that if an input to an AudioWorkletNode is not connected, the input should be represented as an input with a single channel with a Float32Array of length 0. Make it so by passing in nullptr for that input to the AudioWorkletGlobalScope::Process so it can fill the arrays appropriately. Bug: 817145 Change-Id: I82407ed0a9fe84c5012333af8af27f4dd08d29b8 Reviewed-on: https://chromium-review.googlesource.com/953970 Reviewed-by: Hongchan Choi <hongchan@chromium.org> Commit-Queue: Raymond Toy <rtoy@chromium.org> Cr-Commit-Position: refs/heads/master@{#543506} wpt-commits: a2d57e78fca7c449c8419ef56870e834d9c50b18 wpt-pr: 9925 wpt-commits: a2d57e78fca7c449c8419ef56870e834d9c50b18 wpt-pr: 9925
This commit is contained in:
Родитель
bef677031c
Коммит
4a5c201534
|
@ -294899,6 +294899,11 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"webaudio/the-audio-api/the-audioworklet-interface/processors/input-length-processor.js": [
|
||||
[
|
||||
{}
|
||||
]
|
||||
],
|
||||
"webaudio/the-audio-api/the-audioworklet-interface/processors/one-pole-processor.js": [
|
||||
[
|
||||
{}
|
||||
|
@ -364913,6 +364918,12 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-disconnected-input.https.html": [
|
||||
[
|
||||
"/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-disconnected-input.https.html",
|
||||
{}
|
||||
]
|
||||
],
|
||||
"webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-onerror.https.html": [
|
||||
[
|
||||
"/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-onerror.https.html",
|
||||
|
@ -601728,6 +601739,10 @@
|
|||
"99284ab790c09dd7a23a6fa5022e8b08b9e3947d",
|
||||
"testharness"
|
||||
],
|
||||
"webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-disconnected-input.https.html": [
|
||||
"bf3ebb3a403b24078b7e8c2ff7073dcbc486bb27",
|
||||
"testharness"
|
||||
],
|
||||
"webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-onerror.https.html": [
|
||||
"a1cd969fe32a5aca7cd90d0d0955132fd1660b9c",
|
||||
"testharness"
|
||||
|
@ -601752,6 +601767,10 @@
|
|||
"1561b9eede1ee15126fdd9674a6d9d63194b66c2",
|
||||
"support"
|
||||
],
|
||||
"webaudio/the-audio-api/the-audioworklet-interface/processors/input-length-processor.js": [
|
||||
"bd6e7a669a2c445ecfd3de4dd6b48a4d84b214cc",
|
||||
"support"
|
||||
],
|
||||
"webaudio/the-audio-api/the-audioworklet-interface/processors/one-pole-processor.js": [
|
||||
"80b817db4e8d3f49e4f5fe6e97f8e687d16f3159",
|
||||
"support"
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
Test AudioWorkletNode's Disconnected Input Array Length
|
||||
</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/webaudio/resources/audit.js"></script>
|
||||
<script src="/webaudio/resources/audit-util.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script id="layout-test-code">
|
||||
let audit = Audit.createTaskRunner();
|
||||
|
||||
// Arbitrary numbers used to align the test with render quantum boundary.
|
||||
// The sample rate is a power of two to eliminate roundoff in computing
|
||||
// the suspend time needed for the test.
|
||||
let sampleRate = 16384;
|
||||
let renderLength = 8 * RENDER_QUANTUM_FRAMES;
|
||||
let context;
|
||||
|
||||
let filePath = 'processors/input-length-processor.js';
|
||||
|
||||
let testChannelValues = [1, 2, 3];
|
||||
|
||||
// Creates a 3-channel buffer and play with BufferSourceNode. The source
|
||||
// goes through a bypass AudioWorkletNode (gain value of 1).
|
||||
audit.define(
|
||||
{
|
||||
label: 'test',
|
||||
description:
|
||||
'Input array length should be zero for disconnected input'
|
||||
},
|
||||
(task, should) => {
|
||||
context = new OfflineAudioContext({
|
||||
numberOfChannels: 1,
|
||||
length: renderLength,
|
||||
sampleRate: sampleRate
|
||||
});
|
||||
|
||||
context.audioWorklet.addModule(filePath).then(() => {
|
||||
let sourceNode = new ConstantSourceNode(context);
|
||||
let workletNode =
|
||||
new AudioWorkletNode(context, 'input-length-processor');
|
||||
|
||||
workletNode.connect(context.destination);
|
||||
|
||||
// Connect the source now.
|
||||
let connectFrame = RENDER_QUANTUM_FRAMES;
|
||||
|
||||
context.suspend(connectFrame / sampleRate)
|
||||
.then(() => {
|
||||
sourceNode.connect(workletNode);
|
||||
})
|
||||
.then(() => context.resume());
|
||||
;
|
||||
|
||||
// Then disconnect the source after a few renders
|
||||
let disconnectFrame = 3 * RENDER_QUANTUM_FRAMES;
|
||||
context.suspend(disconnectFrame / sampleRate)
|
||||
.then(() => {
|
||||
sourceNode.disconnect(workletNode);
|
||||
})
|
||||
.then(() => context.resume());
|
||||
|
||||
sourceNode.start();
|
||||
context.startRendering()
|
||||
.then(resultBuffer => {
|
||||
let data = resultBuffer.getChannelData(0);
|
||||
|
||||
should(
|
||||
data.slice(0, connectFrame),
|
||||
'Before connecting the source: Input array length')
|
||||
.beConstantValueOf(0);
|
||||
|
||||
// Find where the output is no longer 0.
|
||||
let nonZeroIndex = data.findIndex(x => x > 0);
|
||||
should(nonZeroIndex, 'First non-zero output')
|
||||
.beEqualTo(connectFrame);
|
||||
|
||||
should(
|
||||
data.slice(
|
||||
nonZeroIndex,
|
||||
nonZeroIndex + (disconnectFrame - connectFrame)),
|
||||
'While source is connected: Input array length')
|
||||
.beConstantValueOf(RENDER_QUANTUM_FRAMES);
|
||||
should(
|
||||
data.slice(disconnectFrame),
|
||||
'After disconnecting the source: Input array length')
|
||||
.beConstantValueOf(0);
|
||||
})
|
||||
.then(() => task.done());
|
||||
});
|
||||
});
|
||||
|
||||
audit.run();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,25 @@
|
|||
/**
|
||||
* @class InputLengthProcessor
|
||||
* @extends AudioWorkletProcessor
|
||||
*
|
||||
* This processor class just sets the output to the length of the
|
||||
* input array for verifying that the input length changes when the
|
||||
* input is disconnected.
|
||||
*/
|
||||
class InputLengthProcessor extends AudioWorkletProcessor {
|
||||
constructor() {
|
||||
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);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
registerProcessor('input-length-processor', InputLengthProcessor);
|
Загрузка…
Ссылка в новой задаче