LCOV - code coverage report
Current view: top level - dom/media/webaudio - ChannelMergerNode.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 46 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 11 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim:set ts=2 sw=2 sts=2 et cindent: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #include "mozilla/dom/ChannelMergerNode.h"
       8             : #include "mozilla/dom/ChannelMergerNodeBinding.h"
       9             : #include "AudioNodeEngine.h"
      10             : #include "AudioNodeStream.h"
      11             : 
      12             : namespace mozilla {
      13             : namespace dom {
      14             : 
      15           0 : NS_IMPL_ISUPPORTS_INHERITED0(ChannelMergerNode, AudioNode)
      16             : 
      17           0 : class ChannelMergerNodeEngine final : public AudioNodeEngine
      18             : {
      19             : public:
      20           0 :   explicit ChannelMergerNodeEngine(ChannelMergerNode* aNode)
      21           0 :     : AudioNodeEngine(aNode)
      22             :   {
      23           0 :     MOZ_ASSERT(NS_IsMainThread());
      24           0 :   }
      25             : 
      26           0 :   void ProcessBlocksOnPorts(AudioNodeStream* aStream,
      27             :                             const OutputChunks& aInput,
      28             :                             OutputChunks& aOutput,
      29             :                             bool* aFinished) override
      30             :   {
      31           0 :     MOZ_ASSERT(aInput.Length() >= 1, "Should have one or more input ports");
      32             : 
      33             :     // Get the number of output channels, and allocate it
      34           0 :     size_t channelCount = InputCount();
      35           0 :     bool allNull = true;
      36           0 :     for (size_t i = 0; i < channelCount; ++i) {
      37           0 :       allNull &= aInput[i].IsNull();
      38             :     }
      39           0 :     if (allNull) {
      40           0 :       aOutput[0].SetNull(WEBAUDIO_BLOCK_SIZE);
      41           0 :       return;
      42             :     }
      43             : 
      44           0 :     aOutput[0].AllocateChannels(channelCount);
      45             : 
      46           0 :     for (size_t i = 0; i < channelCount; ++i) {
      47           0 :       float* output = aOutput[0].ChannelFloatsForWrite(i);
      48           0 :       if (aInput[i].IsNull()) {
      49           0 :         PodZero(output, WEBAUDIO_BLOCK_SIZE);
      50             :       } else {
      51           0 :         AudioBlockCopyChannelWithScale(
      52           0 :           static_cast<const float*>(aInput[i].mChannelData[0]),
      53           0 :           aInput[i].mVolume, output);
      54             :       }
      55             :     }
      56             :   }
      57             : 
      58           0 :   size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override
      59             :   {
      60           0 :     return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
      61             :   }
      62             : };
      63             : 
      64           0 : ChannelMergerNode::ChannelMergerNode(AudioContext* aContext,
      65           0 :                                      uint16_t aInputCount)
      66             :   : AudioNode(aContext,
      67             :               1,
      68             :               ChannelCountMode::Explicit,
      69             :               ChannelInterpretation::Speakers)
      70           0 :   , mInputCount(aInputCount)
      71             : {
      72           0 :   mStream = AudioNodeStream::Create(aContext,
      73           0 :                                     new ChannelMergerNodeEngine(this),
      74             :                                     AudioNodeStream::NO_STREAM_FLAGS,
      75           0 :                                     aContext->Graph());
      76           0 : }
      77             : 
      78             : /* static */ already_AddRefed<ChannelMergerNode>
      79           0 : ChannelMergerNode::Create(AudioContext& aAudioContext,
      80             :                           const ChannelMergerOptions& aOptions,
      81             :                           ErrorResult& aRv)
      82             : {
      83           0 :   if (aAudioContext.CheckClosed(aRv)) {
      84           0 :     return nullptr;
      85             :   }
      86             : 
      87           0 :   if (aOptions.mNumberOfInputs == 0 ||
      88           0 :       aOptions.mNumberOfInputs > WebAudioUtils::MaxChannelCount) {
      89           0 :     aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
      90           0 :     return nullptr;
      91             :   }
      92             : 
      93             :   RefPtr<ChannelMergerNode> audioNode =
      94           0 :     new ChannelMergerNode(&aAudioContext, aOptions.mNumberOfInputs);
      95             : 
      96           0 :   audioNode->Initialize(aOptions, aRv);
      97           0 :   if (NS_WARN_IF(aRv.Failed())) {
      98           0 :     return nullptr;
      99             :   }
     100             : 
     101           0 :   return audioNode.forget();
     102             : }
     103             : 
     104             : JSObject*
     105           0 : ChannelMergerNode::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
     106             : {
     107           0 :   return ChannelMergerNodeBinding::Wrap(aCx, this, aGivenProto);
     108             : }
     109             : 
     110             : } // namespace dom
     111             : } // namespace mozilla

Generated by: LCOV version 1.13