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

Side by Side Diff: LayoutTests/webaudio/audiobuffersource-loop-grain-no-duration.html

Issue 912803005: Looping AudioBufferSourceNodes stop only if duration is explicitly given. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase and fix tests Created 5 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 <!doctype html>
2 <html>
3 <head>
4 <title>Test AudioBufferSourceNode looping without explicit duration</title>
5 <script src="resources/compatibility.js"></script>
6 <script src="resources/audio-testing.js"></script>
7 <script src="../resources/js-test.js"></script>
8 </head>
9
10 <body>
11 <script>
12 description("Test AudioBufferSourceNode looping without explicit duration" );
13
14 var context;
15 var buffer;
16 var output;
17 var expected;
18 var sampleRate = 44100;
19 var sourceFrames = 8;
20 // How many loops of the source we want to render.
21 var loopCount = 4;
hongchan 2015/02/20 22:49:46 Out of curiosity, why 4?
22 var renderFrames = sourceFrames * loopCount;
23
24
25 function checkResult(renderedBuffer) {
26 var badIndex = -1;
27 var success = true;
28
29 expected = buffer.getChannelData(0);
30 output = renderedBuffer.getChannelData(0);
31
32 // Verify the output has the expected data.
33 for (var k = 0; k < loopCount; ++k) {
34 for (var n = 0; n < sourceFrames; ++n) {
35 if (expected[n] != output[n + k * sourceFrames]) {
36 if (success)
37 badIndex = n + k * sourceFrames;
38 success = false;
39 }
40 }
41 }
42
43 if (success) {
44 testPassed("Source looped correctly");
45 } else {
46 testFailed("First incorrect sample at index " + badIndex);
47 }
48 }
49
50 function runTest() {
51 window.jsTestIsAsync = true;
52
53 context = new OfflineAudioContext(1, renderFrames, sampleRate);
hongchan 2015/02/20 22:49:46 Can you provide informative comments here? What do
Raymond Toy 2015/02/20 23:06:18 Is the description in lines 59-61 not enough? Or a
hongchan 2015/02/20 23:15:44 I thought more explicit comments about how/why two
54 buffer = createLinearRampBuffer(context, sourceFrames);
55 var source = context.createBufferSource();
56 source.buffer = buffer;
57 source.connect(context.destination);
58
59 // Loop the source, and start the source with an offset, but without a d uration. In this
60 // case, the source should loop "forever". See crbug.com/457009. The c ase where the
61 // duration is given is covered in other tests.
62 source.loop = true;
63 source.start(0, 0);
64 context.startRendering()
65 .then(checkResult)
66 .then(function () { finishJSTest(); });
hongchan 2015/02/20 22:49:46 Can't this be |.then(finishJSTest);| ?
67 }
68
69 runTest();
70 </script>
71 </body>
72 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698