 Chromium Code Reviews
 Chromium Code Reviews Issue 723823002:
  AudioBufferSourceNode loop duration should be the actual duration  (Closed) 
  Base URL: svn://svn.chromium.org/blink/trunk
    
  
    Issue 723823002:
  AudioBufferSourceNode loop duration should be the actual duration  (Closed) 
  Base URL: svn://svn.chromium.org/blink/trunk| Index: LayoutTests/webaudio/audiobuffersource-loop-comprehensive.html | 
| diff --git a/LayoutTests/webaudio/audiobuffersource-loop-comprehensive.html b/LayoutTests/webaudio/audiobuffersource-loop-comprehensive.html | 
| index 1ff7132db8e641e923f371c1531548bd65e4cd28..05cfb0f4fbe13459b36c55c41b62506892047ce1 100644 | 
| --- a/LayoutTests/webaudio/audiobuffersource-loop-comprehensive.html | 
| +++ b/LayoutTests/webaudio/audiobuffersource-loop-comprehensive.html | 
| @@ -87,6 +87,14 @@ var tests = [ | 
| loopStartFrame: 0, loopEndFrame: 30000, renderFrames: 16, playbackRate: 1, | 
| expected: [0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7] }, | 
| +// Start a loop with a duration longer than the buffer. The output should be the data from frame 1 | 
| +// to 6, and then looping from 3 to 5 until 30 frames have been played. | 
| +{ description: "loop from 3 -> 6 with offset 1 for 31 frames", | 
| + loopStartFrame: 3, loopEndFrame: 6, playbackRate: 1, | 
| + offsetFrame: 1, | 
| + durationFrames: 30, | 
| + expected: [1, 2, 3, 4, 5, 3, 4, 5, 3, 4, 5, 3, 4, 5, 3, 4, 5, 3, 4, 5, 3, 4, 5, 3, 4, 5, 3, 4, 5, 3] }, | 
| + | 
| 
hongchan
2015/02/03 23:09:05
I understand there are so many objects and propert
 
Raymond Toy
2015/02/04 00:18:06
Done.
 | 
| ]; | 
| var sampleRate = 44100; | 
| @@ -111,9 +119,26 @@ function runLoopTest(context, testNumber, test) { | 
| // Render each test one after the other, spaced apart by testSpacingSeconds. | 
| var startTime = testNumber * testSpacingSeconds; | 
| - var duration = test.renderFrames / context.sampleRate; | 
| - source.start(startTime, offset); | 
| - source.stop(startTime + duration); | 
| + | 
| + if (test.renderFrames) { | 
| + var duration = test.renderFrames / context.sampleRate; | 
| + if (test.renderFrames > testSpacingFrames || test.renderFrames < 0) { | 
| + testFailed("Test " + testNumber | 
| + + ": renderFrames (" + test.renderFrames + ") outside the range [0, " | 
| + + testSpacingFrames + "]"); | 
| + } | 
| + source.start(startTime, offset); | 
| + source.stop(startTime + duration); | 
| + } else if (test.durationFrames) { | 
| + if (test.durationFrames > testSpacingFrames || test.durationFrames < 0) { | 
| + testFailed("Test " + testNumber | 
| + + ": durationFrames (" + test.durationFrames + ") outside the range [0, " | 
| + + testSpacingFrames + "]"); | 
| + } | 
| + source.start(startTime, offset, test.durationFrames / context.sampleRate); | 
| + } else { | 
| + testFailed("Test " + testNumber + " must specify one of renderFrames or durationFrames"); | 
| + } | 
| } | 
| function runTest() { |