Bug 874024 - Allow creation of ScriptProcessorNodes with 0 input or output channels; r=roc

This commit is contained in:
Ehsan Akhgari 2013-05-23 08:26:21 -04:00
parent c6fb5b210d
commit 15180e2c8e
3 changed files with 42 additions and 1 deletions

View File

@ -208,7 +208,7 @@ AudioContext::CreateScriptProcessor(uint32_t aBufferSize,
uint32_t aNumberOfOutputChannels,
ErrorResult& aRv)
{
if (aNumberOfInputChannels == 0 || aNumberOfOutputChannels == 0 ||
if ((aNumberOfInputChannels == 0 && aNumberOfOutputChannels == 0) ||
aNumberOfInputChannels > MAX_SCRIPT_PROCESSOR_CHANNELS ||
aNumberOfOutputChannels > MAX_SCRIPT_PROCESSOR_CHANNELS ||
!IsValidBufferSize(aBufferSize)) {

View File

@ -62,6 +62,7 @@ MOCHITEST_FILES := \
test_pannerNode.html \
test_scriptProcessorNode.html \
test_scriptProcessorNodeChannelCount.html \
test_scriptProcessorNodeZeroInputOutput.html \
test_singleSourceDest.html \
test_waveShaper.html \
test_waveShaperNoCurve.html \

View File

@ -0,0 +1,40 @@
<!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();
var sp = context.createScriptProcessor(2048, 0, 2);
sp.onaudioprocess = function(e) {
is(e.inputBuffer.numberOfChannels, 0, "Should have 0 input channels");
is(e.outputBuffer.numberOfChannels, 2, "Should have 2 output channels");
sp.onaudioprocess = null;
sp = context.createScriptProcessor(2048, 2, 0);
sp.onaudioprocess = function(e) {
is(e.inputBuffer.numberOfChannels, 2, "Should have 2 input channels");
is(e.outputBuffer.numberOfChannels, 0, "Should have 0 output channels");
sp.onaudioprocess = null;
SpecialPowers.clearUserPref("media.webaudio.enabled");
SimpleTest.finish();
};
};
});
</script>
</pre>
</body>
</html>