Bug 874869 - Disallow setting AudioNode.channelCount to zero; r=roc

This commit is contained in:
Ehsan Akhgari 2013-05-22 11:30:31 -04:00
parent 398c464eef
commit 8225f28a47
6 changed files with 28 additions and 1 deletions

View File

@ -315,6 +315,8 @@ AudioNodeStream::ObtainInputBlock(AudioChunk& aTmpChunk, uint32_t aPortIndex)
return;
}
MOZ_ASSERT(outputChannelCount > 0, "How did this happen?");
AllocateAudioBlock(outputChannelCount, &aTmpChunk);
float silenceChannel[WEBAUDIO_BLOCK_SIZE] = {0.f};
// The static storage here should be 1KB, so it's fine

View File

@ -0,0 +1,15 @@
<script>
var Context0= new AudioContext()
var Panner0=Context0.createPanner();
var BufferSource3=Context0.createBufferSource();
Panner0.channelCount=0;
BufferSource3.connect(Panner0);
BufferSource3.buffer=function(){
var length=1;
var Buffer=Context0.createBuffer(1,length,'44200');
var bufferData= Buffer.getChannelData(0);
for (var i = 0; i < length; ++i) { bufferData[i] = 255;};
return Buffer;
}();
</script>

View File

@ -15,3 +15,4 @@ skip-if(Android||B2G) load 789075-1.html # load failed, bug 833371 for B2G
load 844563.html
load 846612.html
load 852838.html
load 874869.html

View File

@ -159,8 +159,12 @@ public:
virtual uint16_t NumberOfOutputs() const { return 1; }
uint32_t ChannelCount() const { return mChannelCount; }
void SetChannelCount(uint32_t aChannelCount)
void SetChannelCount(uint32_t aChannelCount, ErrorResult& aRv)
{
if (aChannelCount == 0) {
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
return;
}
mChannelCount = aChannelCount;
SendChannelMixingParametersToStream();
}

View File

@ -91,6 +91,10 @@ function createNode(context, buffer, destination) {
is(source.channelCountMode, "max", "Correct channelCountMode for the source node");
is(source.channelInterpretation, "speakers", "Correct channelCountInterpretation for the source node");
expectException(function() {
source.channelCount = 0;
}, DOMException.NOT_SUPPORTED_ERR);
source.buffer = buffer;
ok(source.buffer, "Source node should have a buffer now");

View File

@ -36,6 +36,7 @@ interface AudioNode : EventTarget {
readonly attribute unsigned long numberOfOutputs;
// Channel up-mixing and down-mixing rules for all inputs.
[SetterThrows]
attribute unsigned long channelCount;
attribute ChannelCountMode channelCountMode;
attribute ChannelInterpretation channelInterpretation;