Bug 874869 - Disallow setting AudioNode.channelCount to zero; r=roc
☠☠ backed out by 5b8402ad9f66 ☠ ☠
authorEhsan Akhgari <ehsan@mozilla.com>
Wed, 22 May 2013 11:30:31 -0400
changeset 144135 2718954757e15268961599fc8d446ae8fbcf260b
parent 144134 24997e3446b19b4283278cb4a4763359ca610134
child 144136 d8f3694dd6dfcb7db7357529093d3488794ff1a5
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs874869
milestone24.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 874869 - Disallow setting AudioNode.channelCount to zero; r=roc
content/media/AudioNodeStream.cpp
content/media/test/crashtests/874869.html
content/media/test/crashtests/crashtests.list
content/media/webaudio/AudioNode.h
content/media/webaudio/test/test_singleSourceDest.html
dom/webidl/AudioNode.webidl
--- a/content/media/AudioNodeStream.cpp
+++ b/content/media/AudioNodeStream.cpp
@@ -310,16 +310,18 @@ AudioNodeStream::ObtainInputBlock(AudioC
   }
 
   if (inputChunkCount == 1 &&
       inputChunks[0]->mChannelData.Length() == outputChannelCount) {
     aTmpChunk = *inputChunks[0];
     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
   nsAutoTArray<float, GUESS_AUDIO_CHANNELS*WEBAUDIO_BLOCK_SIZE> downmixBuffer;
 
   for (uint32_t i = 0; i < inputChunkCount; ++i) {
     AudioChunk* chunk = inputChunks[i];
     nsAutoTArray<const void*,GUESS_AUDIO_CHANNELS> channels;
new file mode 100644
--- /dev/null
+++ b/content/media/test/crashtests/874869.html
@@ -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>
\ No newline at end of file
--- a/content/media/test/crashtests/crashtests.list
+++ b/content/media/test/crashtests/crashtests.list
@@ -10,8 +10,9 @@ load 492286-1.xhtml
 load 576612-1.html
 skip-if(Android||B2G) load 691096-1.html # Android sound API can't handle playing large number of sounds at once, bug 852821 for B2G
 load 752784-1.html
 skip-if(Android||B2G) HTTP load 795892-1.html # load failed, bug 833371 for B2G
 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
--- a/content/media/webaudio/AudioNode.h
+++ b/content/media/webaudio/AudioNode.h
@@ -154,18 +154,22 @@ public:
 
   // The following two virtual methods must be implemented by each node type
   // to provide their number of input and output ports. These numbers are
   // constant for the lifetime of the node. Both default to 1.
   virtual uint16_t NumberOfInputs() const { return 1; }
   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();
   }
   ChannelCountMode ChannelCountModeValue() const
   {
     return mChannelCountMode;
   }
   void SetChannelCountModeValue(ChannelCountMode aMode)
--- a/content/media/webaudio/test/test_singleSourceDest.html
+++ b/content/media/webaudio/test/test_singleSourceDest.html
@@ -86,16 +86,20 @@ function createNode(context, buffer, des
   is(source.loop, false, "Source node is not looping");
   is(source.loopStart, 0, "Correct default value for loopStart");
   is(source.loopEnd, 0, "Correct default value for loopEnd");
   ok(!source.buffer, "Source node should not have a buffer when it's created");
   is(source.channelCount, 2, "source node has 2 input channels by default");
   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");
 
   source.connect(destination);
 
   is(source.numberOfInputs, 0, "Source node has 0 inputs");
   is(source.numberOfOutputs, 1, "Source node has 0 outputs");
   is(destination.numberOfInputs, 1, "Destination node has 0 inputs");
--- a/dom/webidl/AudioNode.webidl
+++ b/dom/webidl/AudioNode.webidl
@@ -31,14 +31,15 @@ interface AudioNode : EventTarget {
     [Throws]
     void disconnect(optional unsigned long output = 0);
 
     readonly attribute AudioContext context;
     readonly attribute unsigned long numberOfInputs;
     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;
 
 };