Fix ASSERT fail within AudioBus::processWithGainFrom()
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Jan 2012 05:47:29 +0000 (05:47 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Jan 2012 05:47:29 +0000 (05:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=76685

Patch by Raymond Liu <raymond.liu@intel.com> on 2012-01-30
Reviewed by Daniel Bates.

Source/WebCore:

Test: webaudio/audionode-connect-order.html

* webaudio/AudioBasicProcessorNode.cpp:
(WebCore::AudioBasicProcessorNode::AudioBasicProcessorNode):

LayoutTests:

* webaudio/audionode-connect-order-expected.txt: Added.
* webaudio/audionode-connect-order.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@106332 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/webaudio/audionode-connect-order-expected.txt [new file with mode: 0644]
LayoutTests/webaudio/audionode-connect-order.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/webaudio/AudioBasicProcessorNode.cpp

index e03f209..967a8f9 100644 (file)
@@ -1,3 +1,13 @@
+2012-01-30  Raymond Liu  <raymond.liu@intel.com>
+
+        Fix ASSERT fail within AudioBus::processWithGainFrom()
+        https://bugs.webkit.org/show_bug.cgi?id=76685
+
+        Reviewed by Daniel Bates.
+
+        * webaudio/audionode-connect-order-expected.txt: Added.
+        * webaudio/audionode-connect-order.html: Added.
+
 2012-01-30  Roland Steiner  <rolandsteiner@chromium.org>
 
         <style scoped>: Implement scoped stylesheets and basic application
diff --git a/LayoutTests/webaudio/audionode-connect-order-expected.txt b/LayoutTests/webaudio/audionode-connect-order-expected.txt
new file mode 100644 (file)
index 0000000..eacdc1d
--- /dev/null
@@ -0,0 +1,8 @@
+This tests that we don't trigger an assertion failure due to AudioNode connection order.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/webaudio/audionode-connect-order.html b/LayoutTests/webaudio/audionode-connect-order.html
new file mode 100644 (file)
index 0000000..e03c3f9
--- /dev/null
@@ -0,0 +1,73 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+<script src="../fast/js/resources/js-test-pre.js"></script>
+</head>
+
+<body>
+
+<div id="description"></div>
+<div id="console"></div>
+
+<script>
+description("This tests that we don't trigger an assertion failure due to AudioNode connection order.");
+
+var sampleRate = 44100.0;
+var renderLengthSeconds = 0.125;
+var delayTimeSeconds = 0.1;
+
+function createSinWaveBuffer(context, lengthInSeconds, frequency) {
+    var audioBuffer = context.createBuffer(1, lengthInSeconds * sampleRate, sampleRate);
+
+    var n = audioBuffer.length;
+    var data = audioBuffer.getChannelData(0);
+
+    for (var i = 0; i < n; ++i) {
+        data[i] = Math.sin(frequency * 2 * Math.PI * i / sampleRate);
+    }
+
+    return audioBuffer;
+}
+
+function runTest() {
+    if (window.layoutTestController) {
+        layoutTestController.overridePreference("WebKitWebAudioEnabled", "1");
+        layoutTestController.dumpAsText();
+        layoutTestController.waitUntilDone();
+    }
+    
+    window.jsTestIsAsync = true;
+        
+    // Create offline audio context.
+    var context = new webkitAudioContext(1, sampleRate * renderLengthSeconds, sampleRate);
+    var toneBuffer = createSinWaveBuffer(context, renderLengthSeconds, 880);
+    
+    var bufferSource = context.createBufferSource();
+    bufferSource.buffer = toneBuffer;
+    bufferSource.connect(context.destination);
+
+    var delay = context.createDelayNode();
+    delay.delayTime.value = delayTimeSeconds;
+
+    // We connect delay node to gain node before anything is connected to delay node itself.
+    // We do this because we try to trigger the ASSERT which might be fired due to AudioNode connection order,
+    // especially when gain node and delay node is involved e.g. https://bugs.webkit.org/show_bug.cgi?id=76685.
+
+    var gain = context.createGainNode();
+    gain.connect(context.destination);
+    delay.connect(gain);
+
+    bufferSource.noteOn(0);
+
+    context.oncomplete = finishJSTest;
+    context.startRendering();
+}
+
+runTest();
+
+</script>
+
+<script src="../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
index 25a19e4..a38b0c9 100644 (file)
@@ -1,3 +1,15 @@
+2012-01-30  Raymond Liu  <raymond.liu@intel.com>
+
+        Fix ASSERT fail within AudioBus::processWithGainFrom()
+        https://bugs.webkit.org/show_bug.cgi?id=76685
+
+        Reviewed by Daniel Bates.
+
+        Test: webaudio/audionode-connect-order.html
+
+        * webaudio/AudioBasicProcessorNode.cpp:
+        (WebCore::AudioBasicProcessorNode::AudioBasicProcessorNode):
+
 2012-01-30  Roland Steiner  <rolandsteiner@chromium.org>
 
         <style scoped>: Implement scoped stylesheets and basic application
index 90142f2..c1d0e5d 100644 (file)
@@ -40,7 +40,7 @@ AudioBasicProcessorNode::AudioBasicProcessorNode(AudioContext* context, float sa
     : AudioNode(context, sampleRate)
 {
     addInput(adoptPtr(new AudioNodeInput(this)));
-    addOutput(adoptPtr(new AudioNodeOutput(this, 0)));
+    addOutput(adoptPtr(new AudioNodeOutput(this, 1)));
 
     // The subclass must create m_processor.
 }