Bug 864164 followup - Also send the params to the stream when setting the buffer. r=ehsan
authorPaul Adenot <paul@paul.cx>
Tue, 23 Apr 2013 17:42:40 +0200
changeset 140698 979da3f33fa32edc4a858833e01b0aaa91fd1b91
parent 140697 05cec405039374656a75bae5ff9019fd60510bee
child 140699 4b7de1f2b4a0d7a21dda516d22143b5d8b6f4d7e
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs864164
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 864164 followup - Also send the params to the stream when setting the buffer. r=ehsan
content/media/webaudio/AudioBufferSourceNode.h
content/media/webaudio/test/Makefile.in
content/media/webaudio/test/test_audioBufferSourceNodeLazyLoopParam.html
content/media/webaudio/test/webaudio.js
--- a/content/media/webaudio/AudioBufferSourceNode.h
+++ b/content/media/webaudio/AudioBufferSourceNode.h
@@ -77,16 +77,17 @@ public:
   AudioBuffer* GetBuffer(JSContext* aCx) const
   {
     return mBuffer;
   }
   void SetBuffer(JSContext* aCx, AudioBuffer* aBuffer)
   {
     mBuffer = aBuffer;
     SendBufferParameterToStream(aCx);
+    SendLoopParametersToStream();
   }
   AudioParam* PlaybackRate() const
   {
     return mPlaybackRate;
   }
   bool Loop() const
   {
     return mLoop;
--- a/content/media/webaudio/test/Makefile.in
+++ b/content/media/webaudio/test/Makefile.in
@@ -32,16 +32,17 @@ MOCHITEST_FILES := \
   test_delayNode.html \
   test_delayNodeWithGain.html \
   test_decodeAudioData.html \
   test_dynamicsCompressorNode.html \
   test_gainNode.html \
   test_pannerNode.html \
   test_scriptProcessorNode.html \
   test_singleSourceDest.html \
+  test_audioBufferSourceNodeLazyLoopParam.html \
   ting.ogg \
   ting-expected.wav \
   ting-dualchannel44.1.ogg \
   ting-dualchannel44.1-expected.wav \
   ting-dualchannel48.ogg \
   ting-dualchannel48-expected.wav \
   small-shot.ogg \
   small-shot-expected.wav \
new file mode 100644
--- /dev/null
+++ b/content/media/webaudio/test/test_audioBufferSourceNodeLazyLoopParam.html
@@ -0,0 +1,56 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test AudioBufferSourceNode</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="webaudio.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+SimpleTest.waitForExplicitFinish();
+addLoadEvent(function() {
+  SpecialPowers.setBoolPref("media.webaudio.enabled", true);
+
+  var context = new AudioContext();
+  // silence for half of the buffer, ones after that.
+  var expectedBuffer = context.createBuffer(1, 2048, context.sampleRate);
+  var buffer = context.createBuffer(1, 2048, context.sampleRate);
+  for (var i = 1024; i < 2048; i++) {
+    buffer.getChannelData(0)[i] = 1;
+  }
+  for (var i = 0; i < 2048; i++) {
+    expectedBuffer.getChannelData(0)[i] = 1;
+  }
+
+  var source = context.createBufferSource();
+
+  var sp = context.createScriptProcessor(2048);
+  // we start at the 1024 frames, we should only have ones.
+  source.loop = true;
+  source.loopStart = 1024 / context.sampleRate;
+  source.loopEnd = 2048 / context.sampleRate;
+  source.buffer = buffer;
+  source.start(0, 1024 / context.sampleRate, 1024 / context.sampleRate);
+  source.connect(sp);
+  sp.connect(context.destination);
+  var eventReceived = 0;
+  sp.onaudioprocess = function(e) {
+    eventReceived++;
+    compareBuffers(e.inputBuffer.getChannelData(0), expectedBuffer.getChannelData(0));
+
+    if (eventReceived > 2){
+      sp.onaudioprocess = null;
+
+      SpecialPowers.clearUserPref("media.webaudio.enabled");
+      SimpleTest.finish();
+    }
+  };
+});
+
+</script>
+</pre>
+</body>
+</html>
--- a/content/media/webaudio/test/webaudio.js
+++ b/content/media/webaudio/test/webaudio.js
@@ -38,17 +38,16 @@ function compareBuffers(buf1, buf2,
   }
   sourceOffset = sourceOffset || 0;
   destOffset = destOffset || 0;
   var difference = 0;
   var maxDifference = 0;
   var firstBadIndex = -1;
   for (var i = offset || 0; i < Math.min(buf1.length, (offset || 0) + length); ++i) {
     if (!fuzzyCompare(buf1[i + sourceOffset], buf2[i + destOffset])) {
-      console.log(buf1[i+sourceOffset] + " " + buf2[i+destOffset]);
       difference++;
       maxDifference = Math.max(maxDifference, Math.abs(buf1[i + sourceOffset] - buf2[i + destOffset]));
       if (firstBadIndex == -1) {
         firstBadIndex = i;
       }
     }
   };