Title: [114193] trunk
Revision
114193
Author
commit-qu...@webkit.org
Date
2012-04-13 18:25:30 -0700 (Fri, 13 Apr 2012)

Log Message

AudioContext createChannelMerger() method should have optional argument for number of inputs.
https://bugs.webkit.org/show_bug.cgi?id=83759

Patch by Raymond Liu <raymond....@intel.com> on 2012-04-13
Reviewed by Chris Rogers.

Check https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html for the optional argument.

Source/WebCore:

Test: webaudio/audiochannelmerger-basic.html

* Modules/webaudio/AudioChannelMerger.cpp:
(WebCore):
(WebCore::AudioChannelMerger::create):
(WebCore::AudioChannelMerger::AudioChannelMerger):
* Modules/webaudio/AudioChannelMerger.h:
(AudioChannelMerger):
* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::createChannelMerger):
(WebCore):
* Modules/webaudio/AudioContext.h:
(AudioContext):
* Modules/webaudio/AudioContext.idl:

LayoutTests:

* webaudio/audiochannelmerger-basic-expected.txt: Added.
* webaudio/audiochannelmerger-basic.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (114192 => 114193)


--- trunk/LayoutTests/ChangeLog	2012-04-14 01:20:33 UTC (rev 114192)
+++ trunk/LayoutTests/ChangeLog	2012-04-14 01:25:30 UTC (rev 114193)
@@ -1,3 +1,15 @@
+2012-04-13  Raymond Liu  <raymond....@intel.com>
+
+        AudioContext createChannelMerger() method should have optional argument for number of inputs.
+        https://bugs.webkit.org/show_bug.cgi?id=83759
+
+        Reviewed by Chris Rogers.
+
+        Check https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html for the optional argument.
+
+        * webaudio/audiochannelmerger-basic-expected.txt: Added.
+        * webaudio/audiochannelmerger-basic.html: Added.
+
 2012-04-13  Mihnea Ovidenie  <mih...@adobe.com>
 
         [CSSRegions]Implement NamedFlow::contentNodes attribute

Added: trunk/LayoutTests/webaudio/audiochannelmerger-basic-expected.txt (0 => 114193)


--- trunk/LayoutTests/webaudio/audiochannelmerger-basic-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/webaudio/audiochannelmerger-basic-expected.txt	2012-04-14 01:25:30 UTC (rev 114193)
@@ -0,0 +1,12 @@
+Basic tests for AudioChannelMerger.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS Exception was thrown for numberOfInputs <= 0.
+PASS Exception was thrown for numberOfInputs >= 32.
+PASS AudioChannelMerger created successfully with numberOfInputs = 32.
+PASS AudioChannelMerger created successfully with empty parameter.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/webaudio/audiochannelmerger-basic.html (0 => 114193)


--- trunk/LayoutTests/webaudio/audiochannelmerger-basic.html	                        (rev 0)
+++ trunk/LayoutTests/webaudio/audiochannelmerger-basic.html	2012-04-14 01:25:30 UTC (rev 114193)
@@ -0,0 +1,63 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+<script src=""
+</head>
+
+<body>
+
+<div id="description"></div>
+<div id="console"></div>
+
+<script>
+description("Basic tests for AudioChannelMerger.");
+
+function runTest() {
+    if (window.layoutTestController) {
+        layoutTestController.dumpAsText();
+        layoutTestController.waitUntilDone();
+    }
+
+    window.jsTestIsAsync = true;
+
+    var context = new webkitAudioContext();
+
+    try {
+        var mergernode = context.createChannelMerger(0);
+        testFailed("Exception should be thrown for numberOfInputs <= 0.");
+    } catch(e) {
+        testPassed("Exception was thrown for numberOfInputs <= 0.");
+    }
+
+    try {
+        var mergernode = context.createChannelMerger(33);
+        testFailed("Exception should be thrown for numberOfInputs >= 32.");
+    } catch(e) {
+        testPassed("Exception was thrown for numberOfInputs >= 32.");
+    }
+
+    try {
+        var mergernode = context.createChannelMerger(32);
+        testPassed("AudioChannelMerger created successfully with numberOfInputs = 32.");
+    } catch(e) {
+        testFailed("Failed to create AudioChannelMerger with numberOfInputs = 32.");
+    }
+
+    try {
+        var mergernode = context.createChannelMerger();
+        testPassed("AudioChannelMerger created successfully with empty parameter.");
+    } catch(e) {
+        testFailed("Failed to create AudioChannelMerger with empty parameter.");
+    }
+
+    finishJSTest();
+}
+
+runTest();
+
+</script>
+
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (114192 => 114193)


--- trunk/Source/WebCore/ChangeLog	2012-04-14 01:20:33 UTC (rev 114192)
+++ trunk/Source/WebCore/ChangeLog	2012-04-14 01:25:30 UTC (rev 114193)
@@ -1,3 +1,27 @@
+2012-04-13  Raymond Liu  <raymond....@intel.com>
+
+        AudioContext createChannelMerger() method should have optional argument for number of inputs.
+        https://bugs.webkit.org/show_bug.cgi?id=83759
+
+        Reviewed by Chris Rogers.
+
+        Check https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html for the optional argument.
+
+        Test: webaudio/audiochannelmerger-basic.html
+
+        * Modules/webaudio/AudioChannelMerger.cpp:
+        (WebCore):
+        (WebCore::AudioChannelMerger::create):
+        (WebCore::AudioChannelMerger::AudioChannelMerger):
+        * Modules/webaudio/AudioChannelMerger.h:
+        (AudioChannelMerger):
+        * Modules/webaudio/AudioContext.cpp:
+        (WebCore::AudioContext::createChannelMerger):
+        (WebCore):
+        * Modules/webaudio/AudioContext.h:
+        (AudioContext):
+        * Modules/webaudio/AudioContext.idl:
+
 2012-04-13  Dana Jansens  <dan...@chromium.org>
 
         [chromium] Remove viewport memory restrictions

Modified: trunk/Source/WebCore/Modules/webaudio/AudioChannelMerger.cpp (114192 => 114193)


--- trunk/Source/WebCore/Modules/webaudio/AudioChannelMerger.cpp	2012-04-14 01:20:33 UTC (rev 114192)
+++ trunk/Source/WebCore/Modules/webaudio/AudioChannelMerger.cpp	2012-04-14 01:25:30 UTC (rev 114193)
@@ -37,16 +37,20 @@
 #include "AudioNodeOutput.h"
 
 namespace WebCore {
+
+PassRefPtr<AudioChannelMerger> AudioChannelMerger::create(AudioContext* context, float sampleRate, unsigned numberOfInputs)
+{
+    if (!numberOfInputs || numberOfInputs > AudioContext::maxNumberOfChannels())
+        return 0;
     
-// This is considering that 5.1 (6 channels) is the largest we'll ever deal with.
-// It can easily be increased to support more if the web audio specification is updated.
-const unsigned NumberOfInputs = 6;
+    return adoptRef(new AudioChannelMerger(context, sampleRate, numberOfInputs));      
+}
 
-AudioChannelMerger::AudioChannelMerger(AudioContext* context, float sampleRate)
+AudioChannelMerger::AudioChannelMerger(AudioContext* context, float sampleRate, unsigned numberOfInputs)
     : AudioNode(context, sampleRate)
 {
-    // Create a fixed number of inputs (able to handle the maximum number of channels we deal with).
-    for (unsigned i = 0; i < NumberOfInputs; ++i)
+    // Create the requested number of inputs.
+    for (unsigned i = 0; i < numberOfInputs; ++i)
         addInput(adoptPtr(new AudioNodeInput(this)));
 
     addOutput(adoptPtr(new AudioNodeOutput(this, 1)));

Modified: trunk/Source/WebCore/Modules/webaudio/AudioChannelMerger.h (114192 => 114193)


--- trunk/Source/WebCore/Modules/webaudio/AudioChannelMerger.h	2012-04-14 01:20:33 UTC (rev 114192)
+++ trunk/Source/WebCore/Modules/webaudio/AudioChannelMerger.h	2012-04-14 01:25:30 UTC (rev 114193)
@@ -38,10 +38,7 @@
     
 class AudioChannelMerger : public AudioNode {
 public:
-    static PassRefPtr<AudioChannelMerger> create(AudioContext* context, float sampleRate)
-    {
-        return adoptRef(new AudioChannelMerger(context, sampleRate));      
-    }
+    static PassRefPtr<AudioChannelMerger> create(AudioContext*, float sampleRate, unsigned numberOfInputs);
 
     // AudioNode
     virtual void process(size_t framesToProcess);
@@ -54,7 +51,7 @@
     virtual double tailTime() const OVERRIDE { return 0; }
     virtual double latencyTime() const OVERRIDE { return 0; }
 
-    AudioChannelMerger(AudioContext*, float sampleRate);
+    AudioChannelMerger(AudioContext*, float sampleRate, unsigned numberOfInputs);
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp (114192 => 114193)


--- trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp	2012-04-14 01:20:33 UTC (rev 114192)
+++ trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp	2012-04-14 01:25:30 UTC (rev 114193)
@@ -479,11 +479,25 @@
     return node;
 }
 
-PassRefPtr<AudioChannelMerger> AudioContext::createChannelMerger()
+PassRefPtr<AudioChannelMerger> AudioContext::createChannelMerger(ExceptionCode& ec)
 {
+    const unsigned ChannelMergerDefaultNumberOfInputs = 6;
+    return createChannelMerger(ChannelMergerDefaultNumberOfInputs, ec);
+}
+
+PassRefPtr<AudioChannelMerger> AudioContext::createChannelMerger(size_t numberOfInputs, ExceptionCode& ec)
+{
     ASSERT(isMainThread());
     lazyInitialize();
-    return AudioChannelMerger::create(this, m_destinationNode->sampleRate());
+
+    RefPtr<AudioChannelMerger> node = AudioChannelMerger::create(this, m_destinationNode->sampleRate(), numberOfInputs);
+
+    if (!node.get()) {
+        ec = SYNTAX_ERR;
+        return 0;
+    }
+
+    return node;
 }
 
 PassRefPtr<Oscillator> AudioContext::createOscillator()

Modified: trunk/Source/WebCore/Modules/webaudio/AudioContext.h (114192 => 114193)


--- trunk/Source/WebCore/Modules/webaudio/AudioContext.h	2012-04-14 01:20:33 UTC (rev 114192)
+++ trunk/Source/WebCore/Modules/webaudio/AudioContext.h	2012-04-14 01:25:30 UTC (rev 114193)
@@ -128,7 +128,8 @@
     PassRefPtr<_javascript_AudioNode> createJavaScriptNode(size_t bufferSize, size_t numberOfInputChannels, size_t numberOfOutputChannels, ExceptionCode&);
     PassRefPtr<AudioChannelSplitter> createChannelSplitter(ExceptionCode&);
     PassRefPtr<AudioChannelSplitter> createChannelSplitter(size_t numberOfOutputs, ExceptionCode&);
-    PassRefPtr<AudioChannelMerger> createChannelMerger();
+    PassRefPtr<AudioChannelMerger> createChannelMerger(ExceptionCode&);
+    PassRefPtr<AudioChannelMerger> createChannelMerger(size_t numberOfInputs, ExceptionCode&);
     PassRefPtr<Oscillator> createOscillator();
     PassRefPtr<WaveTable> createWaveTable(Float32Array* real, Float32Array* imag, ExceptionCode&);
 

Modified: trunk/Source/WebCore/Modules/webaudio/AudioContext.idl (114192 => 114193)


--- trunk/Source/WebCore/Modules/webaudio/AudioContext.idl	2012-04-14 01:20:33 UTC (rev 114192)
+++ trunk/Source/WebCore/Modules/webaudio/AudioContext.idl	2012-04-14 01:25:30 UTC (rev 114193)
@@ -80,7 +80,8 @@
         // Channel splitting and merging
         AudioChannelSplitter createChannelSplitter(in [Optional] unsigned long numberOfOutputs)
             raises(DOMException);
-        AudioChannelMerger createChannelMerger();
+        AudioChannelMerger createChannelMerger(in [Optional] unsigned long numberOfInputs)
+            raises(DOMException);
 
         // Offline rendering
         // void prepareOfflineBufferRendering(in unsigned long numberOfChannels, in unsigned long numberOfFrames, in float sampleRate);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to