Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,54 +6,45 @@
</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/webaudio/resources/audit.js"></script>
</head>
<body>
<script id="layout-test-code">
let audit = Audit.createTaskRunner();
<script>
promise_test(async () => {
const sampleRate = 48000;
const renderLength = 512;
const context = new OfflineAudioContext(1, renderLength, sampleRate);

setup(() => {
let sampleRate = 48000;
let renderLength = 512;
let context = new OfflineAudioContext(1, renderLength, sampleRate);
const filePath = 'processors/timing-info-processor.js';

let filePath = 'processors/timing-info-processor.js';
await context.audioWorklet.addModule(filePath);

audit.define(
'Check the timing information from AudioWorkletProcessor',
(task, should) => {
let portWorkletNode =
new AudioWorkletNode(context, 'timing-info-processor');
portWorkletNode.connect(context.destination);
const portWorkletNode =
new AudioWorkletNode(context, 'timing-info-processor');
portWorkletNode.connect(context.destination);

// Suspend at render quantum boundary and check the timing
// information between the main thread and the rendering thread.
[0, 128, 256, 384].map((suspendFrame) => {
context.suspend(suspendFrame/sampleRate).then(() => {
portWorkletNode.port.onmessage = (event) => {
should(event.data.currentFrame,
'currentFrame from the processor at ' + suspendFrame)
.beEqualTo(suspendFrame);
should(event.data.currentTime,
'currentTime from the processor at '
+ context.currentTime)
.beEqualTo(context.currentTime);
context.resume();
};
// Suspend at render quantum boundary and check the timing
// information between the main thread and the rendering thread.
[0, 128, 256, 384].forEach(suspendFrame => {
context.suspend(suspendFrame / sampleRate).then(() => {
portWorkletNode.port.onmessage = (event) => {
assert_equals(
event.data.currentFrame,
suspendFrame,
'currentFrame from the processor at ' + suspendFrame);
assert_equals(
event.data.currentTime,
context.currentTime,
'currentTime from the processor at ' +
context.currentTime);
context.resume();
};

portWorkletNode.port.postMessage('query-timing-info');
});
});

context.startRendering().then(() => {
task.done();
});
});

context.audioWorklet.addModule(filePath).then(() => {
audit.run();
portWorkletNode.port.postMessage('query-timing-info');
});
});
});

await context.startRendering();
}, 'Check the timing information from AudioWorkletProcessor');
</script>
</body>
</html>