Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/Analyser/handle-silent-inputs.html

Issue 2666063003: Continue to process AnalyserNode if inputs are silent. (Closed)
Patch Set: Add test Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!doctype html>
2 <html>
3 <head>
4 <script src="../../resources/testharness.js"></script>
5 <script src="../../resources/testharnessreport.js"></script>
6 <script src="../resources/audit-util.js"></script>
7 <script src="../resources/audit.js"></script>
8 <title>Handle Silent Inputs to AnalyserNode</title>
9 </head>
10
11 <body>
12 <script>
13 let audit = Audit.createTaskRunner();
14 let sampleRate = 16000;
15 let renderDuration = 1;
16 let renderFrames = renderDuration * sampleRate;
17
18 audit.define('connected', function(task, should) {
19 task.describe('Test handling of silent inputs');
20
21 tester(should, false).then(task.done.bind(task));
22 });
23
24 audit.define('auto-pull', function(task, should) {
25 task.describe('Test handling of silent inputs');
26
27 tester(should, true).then(task.done.bind(task));
28 });
29
30 audit.run();
31
32 function tester(should, isAutoPullTest) {
33 // Connect an oscillator to an analyser for testing the time data of the
34 // analyser after the oscillator stops.
35 let context = new OfflineAudioContext(1, renderFrames, sampleRate);
36 let source = new OscillatorNode(context);
37 let analyser = new AnalyserNode(context, {fftSize: 128});
38 let timeData = new Float32Array(analyser.fftSize);
39 timeData.fill(NaN);
40
41 source.connect(analyser);
42
43 // For the automatic pull test, leave the analyser output disconnected.
44 if (isAutoPullTest) {
45 source.connect(context.destination);
46 } else {
47 analyser.connect(context.destination);
48 }
49
50 source.start();
51
52 // Stop the source well in advance of when we want to get the time data
53 // from the analyser.
54 let stopTime = 0.1;
55 let dataTime = 0.5;
56
57 source.stop(stopTime);
58 context.suspend(dataTime)
59 .then(() => { analyser.getFloatTimeDomainData(timeData); })
60 .then(context.resume.bind(context));
61
62 return context.startRendering().then(buffer => {
63 should(timeData, 'Analyser time data at time ' + dataTime)
64 .beConstantValueOf(0);
65 });
66 }
67 </script>
68 </body>
69 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698