Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 8742769

Browse files
committed
Bug 864164 followup - Also send the params to the stream when setting the buffer. r=ehsan
1 parent f4ede88 commit 8742769

4 files changed

Lines changed: 58 additions & 1 deletion

File tree

content/media/webaudio/AudioBufferSourceNode.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class AudioBufferSourceNode : public AudioNode,
8282
{
8383
mBuffer = aBuffer;
8484
SendBufferParameterToStream(aCx);
85+
SendLoopParametersToStream();
8586
}
8687
AudioParam* PlaybackRate() const
8788
{

content/media/webaudio/test/Makefile.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ MOCHITEST_FILES := \
3737
test_pannerNode.html \
3838
test_scriptProcessorNode.html \
3939
test_singleSourceDest.html \
40+
test_audioBufferSourceNodeLazyLoopParam.html \
4041
ting.ogg \
4142
ting-expected.wav \
4243
ting-dualchannel44.1.ogg \
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<!DOCTYPE HTML>
2+
<html>
3+
<head>
4+
<title>Test AudioBufferSourceNode</title>
5+
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
6+
<script type="text/javascript" src="webaudio.js"></script>
7+
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
8+
</head>
9+
<body>
10+
<pre id="test">
11+
<script class="testbody" type="text/javascript">
12+
13+
SimpleTest.waitForExplicitFinish();
14+
addLoadEvent(function() {
15+
SpecialPowers.setBoolPref("media.webaudio.enabled", true);
16+
17+
var context = new AudioContext();
18+
// silence for half of the buffer, ones after that.
19+
var expectedBuffer = context.createBuffer(1, 2048, context.sampleRate);
20+
var buffer = context.createBuffer(1, 2048, context.sampleRate);
21+
for (var i = 1024; i < 2048; i++) {
22+
buffer.getChannelData(0)[i] = 1;
23+
}
24+
for (var i = 0; i < 2048; i++) {
25+
expectedBuffer.getChannelData(0)[i] = 1;
26+
}
27+
28+
var source = context.createBufferSource();
29+
30+
var sp = context.createScriptProcessor(2048);
31+
// we start at the 1024 frames, we should only have ones.
32+
source.loop = true;
33+
source.loopStart = 1024 / context.sampleRate;
34+
source.loopEnd = 2048 / context.sampleRate;
35+
source.buffer = buffer;
36+
source.start(0, 1024 / context.sampleRate, 1024 / context.sampleRate);
37+
source.connect(sp);
38+
sp.connect(context.destination);
39+
var eventReceived = 0;
40+
sp.onaudioprocess = function(e) {
41+
eventReceived++;
42+
compareBuffers(e.inputBuffer.getChannelData(0), expectedBuffer.getChannelData(0));
43+
44+
if (eventReceived > 2){
45+
sp.onaudioprocess = null;
46+
47+
SpecialPowers.clearUserPref("media.webaudio.enabled");
48+
SimpleTest.finish();
49+
}
50+
};
51+
});
52+
53+
</script>
54+
</pre>
55+
</body>
56+
</html>

content/media/webaudio/test/webaudio.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ function compareBuffers(buf1, buf2,
4343
var firstBadIndex = -1;
4444
for (var i = offset || 0; i < Math.min(buf1.length, (offset || 0) + length); ++i) {
4545
if (!fuzzyCompare(buf1[i + sourceOffset], buf2[i + destOffset])) {
46-
console.log(buf1[i+sourceOffset] + " " + buf2[i+destOffset]);
4746
difference++;
4847
maxDifference = Math.max(maxDifference, Math.abs(buf1[i + sourceOffset] - buf2[i + destOffset]));
4948
if (firstBadIndex == -1) {

0 commit comments

Comments
 (0)