Open karlt opened 4 years ago
One issue appears to be
await context.audioWorklet.addModule('channel-count-processor.js')
is not executed for the second test?
<!DOCTYPE html>
<html>
<head>
<title>
Test the construction of AudioWorkletNode with real-time context
</title>
</head>
<body>
<script id="layout-test-code">
const context = new AudioContext();
(async function() {
Promise.all([
new Promise(async resolve => {
await context.audioWorklet.addModule(
'channel-count-processor.js');
// Test if the output channe count dynamically changes if the input
// and output is 1.
//audit.define(
// {label: 'Dynamically change the channel count to if unspecified.'},
// (task, should) => {
// Use arbitrary parameters for the test.
const buffer = new AudioBuffer({
numberOfChannels: 17,
length: 1,
sampleRate: context.sampleRate,
});
const source = new AudioBufferSourceNode(context);
source.buffer = buffer;
const node = new AudioWorkletNode(context, 'channel-count', {
numberOfInputs: 1,
numberOfOutputs: 1,
});
node.port.onmessage = (message) => {
const expected = message.data;
resolve([expected.outputChannel, 'The expected output channel count is 17']) // 17
};
// We need to make an actual connection becasue the channel count
// change happen when the rendering starts. It is to test if the
// channel count adapts to the upstream node correctly.
source.connect(node).connect(context.destination);
source.start();
}),
// });
// Test if outputChannelCount is honored as expected even if the input
// and output is 1.
//audit.define(
// {label: 'Givien outputChannelCount must be honored.'},
// (task, should) => {
new Promise(async resolve => {
await context.audioWorklet.addModule(
'channel-count-processor.js');
const node = new AudioWorkletNode(
context, 'channel-count', {
numberOfInputs: 1,
numberOfOutputs: 1,
outputChannelCount: [2],
});
node.port.onmessage = (message) => {
const expected = message.data;
resolve([expected.outputChannel, 'The expected output channel count 2']) // 2
// task.done();
};
// We need to make an actual connection becasue the channel count
// change might happen when the rendering starts. It is to test
// if the specified channel count is kept correctly.
node.connect(context.destination);
})
]).then(([
[a],
[b]
]) => console.log(a === 17 && b === 2, {
a, b
}))
//audit.run();
})();
</script>
</body>
</html>
e.g. https://community-tc.services.mozilla.com/tasks/LjF7rW4JQzGDF14Q6PP3bA
IIUC Chrome's implementation can allow
ChannelCountProcessor.process()
to be called betweenAudioWorkletNode
construction and connection and the subsequentstart()
on the connectedsource
. This would be spec compliant butChannelCountProcessor.process()
would then find channel counts of 1 becausesource
has not yet started and so is not actively processing. i.e. I think the problem is in the test.(I guess I need to reference the pull request conversation to link the records.)