LCOV - code coverage report
Current view: top level - dom/media/webaudio - OscillatorNode.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 25 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 14 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             : #ifndef OscillatorNode_h_
       8             : #define OscillatorNode_h_
       9             : 
      10             : #include "AudioScheduledSourceNode.h"
      11             : #include "AudioParam.h"
      12             : #include "PeriodicWave.h"
      13             : #include "mozilla/dom/OscillatorNodeBinding.h"
      14             : 
      15             : namespace mozilla {
      16             : namespace dom {
      17             : 
      18             : class AudioContext;
      19             : struct OscillatorOptions;
      20             : 
      21             : class OscillatorNode final : public AudioScheduledSourceNode
      22             :                            , public MainThreadMediaStreamListener
      23             : {
      24             : public:
      25             :   static already_AddRefed<OscillatorNode>
      26             :   Create(AudioContext& aAudioContext, const OscillatorOptions& aOptions,
      27             :          ErrorResult& aRv);
      28             : 
      29             :   NS_DECL_ISUPPORTS_INHERITED
      30           0 :   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(OscillatorNode, AudioScheduledSourceNode)
      31             : 
      32             :   static already_AddRefed<OscillatorNode>
      33           0 :   Constructor(const GlobalObject& aGlobal, AudioContext& aAudioContext,
      34             :               const OscillatorOptions& aOptions, ErrorResult& aRv)
      35             :   {
      36           0 :     return Create(aAudioContext, aOptions, aRv);
      37             :   }
      38             : 
      39             :   JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
      40             : 
      41             :   void DestroyMediaStream() override;
      42             : 
      43           0 :   uint16_t NumberOfInputs() const final override
      44             :   {
      45           0 :     return 0;
      46             :   }
      47             : 
      48           0 :   OscillatorType Type() const
      49             :   {
      50           0 :     return mType;
      51             :   }
      52           0 :   void SetType(OscillatorType aType, ErrorResult& aRv)
      53             :   {
      54           0 :     if (aType == OscillatorType::Custom) {
      55             :       // ::Custom can only be set by setPeriodicWave().
      56             :       // https://github.com/WebAudio/web-audio-api/issues/105 for exception.
      57           0 :       aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
      58           0 :       return;
      59             :     }
      60           0 :     mType = aType;
      61           0 :     SendTypeToStream();
      62             :   }
      63             : 
      64           0 :   AudioParam* Frequency() const
      65             :   {
      66           0 :     return mFrequency;
      67             :   }
      68           0 :   AudioParam* Detune() const
      69             :   {
      70           0 :     return mDetune;
      71             :   }
      72             : 
      73             :   void Start(double aWhen, ErrorResult& aRv) override;
      74             :   void Stop(double aWhen, ErrorResult& aRv) override;
      75             : 
      76           0 :   void SetPeriodicWave(PeriodicWave& aPeriodicWave)
      77             :   {
      78           0 :     mPeriodicWave = &aPeriodicWave;
      79             :     // SendTypeToStream will call SendPeriodicWaveToStream for us.
      80           0 :     mType = OscillatorType::Custom;
      81           0 :     SendTypeToStream();
      82           0 :   }
      83             : 
      84             :   void NotifyMainThreadStreamFinished() override;
      85             : 
      86           0 :   const char* NodeType() const override
      87             :   {
      88           0 :     return "OscillatorNode";
      89             :   }
      90             : 
      91             :   size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const override;
      92             :   size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override;
      93             : 
      94             : private:
      95             :   explicit OscillatorNode(AudioContext* aContext);
      96           0 :   ~OscillatorNode() = default;
      97             : 
      98             :   void SendTypeToStream();
      99             :   void SendPeriodicWaveToStream();
     100             : 
     101             :   OscillatorType mType;
     102             :   RefPtr<PeriodicWave> mPeriodicWave;
     103             :   RefPtr<AudioParam> mFrequency;
     104             :   RefPtr<AudioParam> mDetune;
     105             :   bool mStartCalled;
     106             : };
     107             : 
     108             : } // namespace dom
     109             : } // namespace mozilla
     110             : 
     111             : #endif

Generated by: LCOV version 1.13