Bug 1265408 - Log biquad channel change warning to console; r?padenot draft
authorDan Minor <dminor@mozilla.com>
Fri, 03 Jun 2016 14:17:41 -0400
changeset 375240 3a15f1570741a6d336d99c552ac04833b78d4706
parent 375239 bdb76104a4417d0f595fd88afe7e2c11ea22d733
child 522793 eceb77a4190c863dc9cb3b3b21c8ca2afa681795
push id20196
push userdminor@mozilla.com
push dateFri, 03 Jun 2016 18:26:34 +0000
reviewerspadenot
bugs1265408
milestone49.0a1
Bug 1265408 - Log biquad channel change warning to console; r?padenot MozReview-Commit-ID: G16wgfKr4I6
dom/locales/en-US/chrome/dom/dom.properties
dom/media/webaudio/BiquadFilterNode.cpp
--- a/dom/locales/en-US/chrome/dom/dom.properties
+++ b/dom/locales/en-US/chrome/dom/dom.properties
@@ -226,8 +226,9 @@ RewriteYoutubeEmbed=Rewriting old-style 
 RewriteYoutubeEmbedInvalidQuery=Rewriting old-style Youtube Flash embed (%S) to iframe embed (%S). Query was invalid and removed from URL. Please update page to use iframe instead of embed/object, if possible.
 # LOCALIZATION NOTE: Do not translate "ServiceWorker". %1$S is the ServiceWorker scope URL. %2$S is an error string.
 PushMessageDecryptionFailure=The ServiceWorker for scope ‘%1$S’ encountered an error decrypting a push message: ‘%2$S’. For help with encryption, please see https://developer.mozilla.org/en-US/docs/Web/API/Push_API/Using_the_Push_API#Encryption
 # LOCALIZATION NOTE: %1$S is the type of a DOM event. 'passive' is a literal parameter from the DOM spec.
 PreventDefaultFromPassiveListenerWarning=Ignoring ‘preventDefault()’ call on event of type ‘%1$S’ from a listener registered as ‘passive’.
 NavigatorBatteryWarning=navigator.battery is deprecated. Use navigator.getBattery() instead.
 FileLastModifiedDateWarning=File.lastModifiedDate is deprecated. Use File.lastModified instead.
 IIRFilterChannelCountChangeWarning=IIRFilterNode channel count changes may produce audio glitches.
+BiquadFilterChannelCountChangeWarning=BiquadFilterNode channel count changes may produce audio glitches.
--- a/dom/media/webaudio/BiquadFilterNode.cpp
+++ b/dom/media/webaudio/BiquadFilterNode.cpp
@@ -72,26 +72,29 @@ SetParamsOnBiquad(WebCore::Biquad& aBiqu
     NS_NOTREACHED("We should never see the alternate names here");
     break;
   }
 }
 
 class BiquadFilterNodeEngine final : public AudioNodeEngine
 {
 public:
-  BiquadFilterNodeEngine(AudioNode* aNode, AudioDestinationNode* aDestination)
+  BiquadFilterNodeEngine(AudioNode* aNode,
+                         AudioDestinationNode* aDestination,
+                         uint64_t aWindowID)
     : AudioNodeEngine(aNode)
     , mDestination(aDestination->Stream())
     // Keep the default values in sync with the default values in
     // BiquadFilterNode::BiquadFilterNode
     , mType(BiquadFilterType::Lowpass)
     , mFrequency(350.f)
     , mDetune(0.f)
     , mQ(1.f)
     , mGain(0.f)
+    , mWindowID(aWindowID)
   {
   }
 
   enum Parameteres {
     TYPE,
     FREQUENCY,
     DETUNE,
     Q,
@@ -168,17 +171,18 @@ public:
 
     } else if(mBiquads.Length() != aInput.ChannelCount()){
       if (mBiquads.IsEmpty()) {
         RefPtr<PlayingRefChangeHandler> refchanged =
           new PlayingRefChangeHandler(aStream, PlayingRefChangeHandler::ADDREF);
         aStream->Graph()->
           DispatchToMainThreadAfterStreamStateUpdate(refchanged.forget());
       } else { // Help people diagnose bug 924718
-        NS_WARNING("BiquadFilterNode channel count changes may produce audio glitches");
+        WebAudioUtils::LogToDeveloperConsole(mWindowID,
+                                             "BiquadFilterChannelCountChangeWarning");
       }
 
       // Adjust the number of biquads based on the number of channels
       mBiquads.SetLength(aInput.ChannelCount());
     }
 
     uint32_t numberOfChannels = mBiquads.Length();
     aOutput->AllocateChannels(numberOfChannels);
@@ -232,31 +236,33 @@ public:
 private:
   AudioNodeStream* mDestination;
   BiquadFilterType mType;
   AudioParamTimeline mFrequency;
   AudioParamTimeline mDetune;
   AudioParamTimeline mQ;
   AudioParamTimeline mGain;
   nsTArray<WebCore::Biquad> mBiquads;
+  uint64_t mWindowID;
 };
 
 BiquadFilterNode::BiquadFilterNode(AudioContext* aContext)
   : AudioNode(aContext,
               2,
               ChannelCountMode::Max,
               ChannelInterpretation::Speakers)
   , mType(BiquadFilterType::Lowpass)
   , mFrequency(new AudioParam(this, BiquadFilterNodeEngine::FREQUENCY,
                               350.f, "frequency"))
   , mDetune(new AudioParam(this, BiquadFilterNodeEngine::DETUNE, 0.f, "detune"))
   , mQ(new AudioParam(this, BiquadFilterNodeEngine::Q, 1.f, "Q"))
   , mGain(new AudioParam(this, BiquadFilterNodeEngine::GAIN, 0.f, "gain"))
 {
-  BiquadFilterNodeEngine* engine = new BiquadFilterNodeEngine(this, aContext->Destination());
+  uint64_t windowID = aContext->GetParentObject()->WindowID();
+  BiquadFilterNodeEngine* engine = new BiquadFilterNodeEngine(this, aContext->Destination(), windowID);
   mStream = AudioNodeStream::Create(aContext, engine,
                                     AudioNodeStream::NO_STREAM_FLAGS);
 }
 
 BiquadFilterNode::~BiquadFilterNode()
 {
 }