Bug 1500238 output null from StereoPannerNode when input is null r=padenot
authorKarl Tomlinson <karlt+@karlt.net>
Fri, 19 Oct 2018 09:25:25 +0000
changeset 490549 17f777b161890b63b207c412549e4afc7129fa32
parent 490548 cc7ddb5861a8de34ad979db33ebb46ff1bbfd8c5
child 490550 01b1f806550b9a8c610c653b842305e1f3e9ad3a
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewerspadenot
bugs1500238
milestone64.0a1
Bug 1500238 output null from StereoPannerNode when input is null r=padenot This is necessary for efficient processing of silence, and is consistent with behavior of other nodes. A null block current has a single channel of silence, which isn't aligned with the current spec, but is consistent with the direction of https://github.com/WebAudio/web-audio-api/issues/1471#issuecomment-405668690 Depends on D9210 Differential Revision: https://phabricator.services.mozilla.com/D9211
dom/media/webaudio/StereoPannerNode.cpp
--- a/dom/media/webaudio/StereoPannerNode.cpp
+++ b/dom/media/webaudio/StereoPannerNode.cpp
@@ -108,23 +108,23 @@ public:
   virtual void ProcessBlock(AudioNodeStream* aStream,
                             GraphTime aFrom,
                             const AudioBlock& aInput,
                             AudioBlock* aOutput,
                             bool *aFinished) override
   {
     // The output of this node is always stereo, no matter what the inputs are.
     MOZ_ASSERT(aInput.ChannelCount() <= 2);
-    aOutput->AllocateChannels(2);
     bool monoToStereo = aInput.ChannelCount() == 1;
 
     if (aInput.IsNull()) {
       // If input is silent, so is the output
-      SetToSilentStereoBlock(aOutput);
+      aOutput->SetNull(WEBAUDIO_BLOCK_SIZE);
     } else if (mPan.HasSimpleValue()) {
+      aOutput->AllocateChannels(2);
       float panning = mPan.GetValue();
       // If the panning is 0.0, we can simply copy the input to the
       // output with gain applied, up-mixing to stereo if needed.
       if (panning == 0.0f) {
         UpmixToStereoIfNeeded(aInput, aOutput);
       } else {
         // Optimize the case where the panning is constant for this processing
         // block: we can just apply a constant gain on the left and right
@@ -133,16 +133,17 @@ public:
 
         GetGainValuesForPanning(panning, monoToStereo, gainL, gainR);
         ApplyStereoPanning(aInput, aOutput,
                            gainL * aInput.mVolume,
                            gainR * aInput.mVolume,
                            panning <= 0);
       }
     } else {
+      aOutput->AllocateChannels(2);
       float computedGain[2*WEBAUDIO_BLOCK_SIZE + 4];
       bool onLeft[WEBAUDIO_BLOCK_SIZE];
 
       float values[WEBAUDIO_BLOCK_SIZE];
       StreamTime tick = mDestination->GraphTimeToStreamTime(aFrom);
       mPan.GetValuesAtTime(tick, values, WEBAUDIO_BLOCK_SIZE);
 
       float* alignedComputedGain = ALIGNED16(computedGain);