b=906966 limit ConvolverNode and PannerNode input channel count through channelCount and channelCountMode r=ehsan
authorKarl Tomlinson <karlt+@karlt.net>
Thu, 05 Sep 2013 07:44:35 +1200
changeset 145493 4d5107aea7080cbc0e7e4ac11e37da2f81caeffe
parent 145492 2ee662f747a2194cf28a7678aa3b1f8555f26e6b
child 145494 15a71c6cb0d3ab794fee0b4307ef108162e66f05
push id33296
push userktomlinson@mozilla.com
push dateWed, 04 Sep 2013 20:32:35 +0000
treeherdermozilla-inbound@15a71c6cb0d3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs906966
milestone26.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
b=906966 limit ConvolverNode and PannerNode input channel count through channelCount and channelCountMode r=ehsan
content/media/webaudio/AudioNode.h
content/media/webaudio/ConvolverNode.h
content/media/webaudio/PannerNode.h
content/media/webaudio/blink/HRTFPanner.cpp
content/media/webaudio/blink/Reverb.cpp
dom/webidl/AudioNode.webidl
--- a/content/media/webaudio/AudioNode.h
+++ b/content/media/webaudio/AudioNode.h
@@ -166,17 +166,17 @@ public:
     }
     mChannelCount = aChannelCount;
     SendChannelMixingParametersToStream();
   }
   ChannelCountMode ChannelCountModeValue() const
   {
     return mChannelCountMode;
   }
-  void SetChannelCountModeValue(ChannelCountMode aMode)
+  virtual void SetChannelCountModeValue(ChannelCountMode aMode, ErrorResult& aRv)
   {
     mChannelCountMode = aMode;
     SendChannelMixingParametersToStream();
   }
   ChannelInterpretation ChannelInterpretationValue() const
   {
     return mChannelInterpretation;
   }
--- a/content/media/webaudio/ConvolverNode.h
+++ b/content/media/webaudio/ConvolverNode.h
@@ -35,16 +35,32 @@ public:
 
   bool Normalize() const
   {
     return mNormalize;
   }
 
   void SetNormalize(bool aNormal);
 
+  virtual void SetChannelCount(uint32_t aChannelCount, ErrorResult& aRv) MOZ_OVERRIDE
+  {
+    if (aChannelCount > 2) {
+      aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
+      return;
+    }
+    AudioNode::SetChannelCount(aChannelCount, aRv);
+  }
+  virtual void SetChannelCountModeValue(ChannelCountMode aMode, ErrorResult& aRv) MOZ_OVERRIDE
+  {
+    if (aMode == ChannelCountMode::Max) {
+      aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
+      return;
+    }
+    AudioNode::SetChannelCountModeValue(aMode, aRv);
+  }
   virtual void NotifyInputConnected() MOZ_OVERRIDE
   {
     mMediaStreamGraphUpdateIndexAtLastInputConnection =
       mStream->Graph()->GetCurrentGraphUpdateIndex();
   }
   bool AcceptPlayingRefRelease(int64_t aLastGraphUpdateIndexProcessed) const
   {
     // Reject any requests to release mPlayingRef if the request was issued
--- a/content/media/webaudio/PannerNode.h
+++ b/content/media/webaudio/PannerNode.h
@@ -29,16 +29,33 @@ public:
   virtual ~PannerNode();
 
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   virtual void DestroyMediaStream() MOZ_OVERRIDE;
 
+  virtual void SetChannelCount(uint32_t aChannelCount, ErrorResult& aRv) MOZ_OVERRIDE
+  {
+    if (aChannelCount > 2) {
+      aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
+      return;
+    }
+    AudioNode::SetChannelCount(aChannelCount, aRv);
+  }
+  virtual void SetChannelCountModeValue(ChannelCountMode aMode, ErrorResult& aRv) MOZ_OVERRIDE
+  {
+    if (aMode == ChannelCountMode::Max) {
+      aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
+      return;
+    }
+    AudioNode::SetChannelCountModeValue(aMode, aRv);
+  }
+
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(PannerNode, AudioNode)
 
   PanningModelType PanningModel() const
   {
     return mPanningModel;
   }
   void SetPanningModel(PanningModelType aPanningModel)
--- a/content/media/webaudio/blink/HRTFPanner.cpp
+++ b/content/media/webaudio/blink/HRTFPanner.cpp
@@ -110,24 +110,23 @@ int HRTFPanner::calculateDesiredAzimuthI
     return desiredAzimuthIndex;
 }
 
 void HRTFPanner::pan(double desiredAzimuth, double elevation, const AudioChunk* inputBus, AudioChunk* outputBus, TrackTicks framesToProcess)
 {
     unsigned numInputChannels =
         inputBus->IsNull() ? 0 : inputBus->mChannelData.Length();
 
-    bool isInputGood = inputBus && numInputChannels <= 2;
-    MOZ_ASSERT(isInputGood);
+    MOZ_ASSERT(numInputChannels <= 2);
     MOZ_ASSERT(framesToProcess <= inputBus->mDuration);
 
     bool isOutputGood = outputBus && outputBus->mChannelData.Length() == 2 && framesToProcess <= outputBus->mDuration;
     MOZ_ASSERT(isOutputGood);
 
-    if (!isInputGood || !isOutputGood) {
+    if (!isOutputGood) {
         if (outputBus)
             outputBus->SetNull(outputBus->mDuration);
         return;
     }
 
     HRTFDatabase* database = m_databaseLoader->database();
     if (!database) { // not yet loaded
         outputBus->SetNull(outputBus->mDuration);
--- a/content/media/webaudio/blink/Reverb.cpp
+++ b/content/media/webaudio/blink/Reverb.cpp
@@ -141,20 +141,17 @@ void Reverb::process(const AudioChunk* s
     bool isSafeToProcess = sourceBus && destinationBus && sourceBus->mChannelData.Length() > 0 && destinationBus->mChannelData.Length() > 0
         && framesToProcess <= MaxFrameSize && framesToProcess <= size_t(sourceBus->mDuration) && framesToProcess <= size_t(destinationBus->mDuration);
 
     MOZ_ASSERT(isSafeToProcess);
     if (!isSafeToProcess)
         return;
 
     // For now only handle mono or stereo output
-    if (destinationBus->mChannelData.Length() > 2) {
-        destinationBus->SetNull(destinationBus->mDuration);
-        return;
-    }
+    MOZ_ASSERT(destinationBus->mChannelData.Length() <= 2);
 
     float* destinationChannelL = static_cast<float*>(const_cast<void*>(destinationBus->mChannelData[0]));
     const float* sourceBusL = static_cast<const float*>(sourceBus->mChannelData[0]);
 
     // Handle input -> output matrixing...
     size_t numInputChannels = sourceBus->mChannelData.Length();
     size_t numOutputChannels = destinationBus->mChannelData.Length();
     size_t numReverbChannels = m_convolvers.Length();
--- a/dom/webidl/AudioNode.webidl
+++ b/dom/webidl/AudioNode.webidl
@@ -33,13 +33,14 @@ interface AudioNode : EventTarget {
 
     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;
+    [SetterThrows]
     attribute ChannelCountMode channelCountMode;
     attribute ChannelInterpretation channelInterpretation;
 
 };