Commit 0724725c authored by rtoy@chromium.org's avatar rtoy@chromium.org

Looping one-sample AudioBufferSourceNode should work.

BUG=421121
TEST=audiobuffersource-one-sample-loop.html

Review URL: https://codereview.chromium.org/637653002

git-svn-id: svn://svn.chromium.org/blink/trunk@183687 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent ae0e239e
Test AudioBufferSourceNode With Looping a Single-Sample Buffer
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS All samples equal to 1
PASS successfullyParsed is true
TEST COMPLETE
<!doctype html>
<html>
<head>
<title>Test AudioBufferSourceNode With Looping a Single-Sample Buffer</title>
<script src="resources/compatibility.js"></script>
<script src="resources/audio-testing.js"></script>
<script src="../resources/js-test.js"></script>
</head>
<body>
<script>
description("Test AudioBufferSourceNode With Looping a Single-Sample Buffer");
var context;
var source;
var buffer;
var renderedData;
var sampleRate = 44100;
var testDurationSamples = 1000;
function checkResult (event) {
var success = true;
renderedData = event.renderedBuffer.getChannelData(0);
// Check that the rendered data is all ones, like the buffer source.
for (k = 0; k < renderedData.length; ++k) {
if (renderedData[k] != 1) {
success = false;
testFailed("Expected all ones, but sample " + k + " is " + renderedData[k]);
break;
}
}
if (success)
testPassed("All samples equal to 1");
finishJSTest();
}
function runTest() {
window.jsTestIsAsync = true;
// Create the offline context for the test.
context = new OfflineAudioContext(1, testDurationSamples, sampleRate);
context.oncomplete = checkResult;
// Create the single sample buffer
buffer = createConstantBuffer(context, 1, 1);
// Create the source and connect it to the destination
source = context.createBufferSource();
source.buffer = buffer;
source.loop = true;
source.connect(context.destination);
source.start();
// Render it!
context.startRendering();
}
runTest();
succesfullyParsed = true;
</script>
</body>
</html>
...@@ -236,7 +236,7 @@ bool AudioBufferSourceNode::renderFromBuffer(AudioBus* bus, unsigned destination ...@@ -236,7 +236,7 @@ bool AudioBufferSourceNode::renderFromBuffer(AudioBus* bus, unsigned destination
double pitchRate = totalPitchRate(); double pitchRate = totalPitchRate();
// Sanity check that our playback rate isn't larger than the loop size. // Sanity check that our playback rate isn't larger than the loop size.
if (pitchRate >= virtualDeltaFrames) if (pitchRate > virtualDeltaFrames)
return false; return false;
// Get local copy. // Get local copy.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment