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 ConstantSourceNode_h_ 8 #define ConstantSourceNode_h_ 9 10 #include "AudioScheduledSourceNode.h" 11 #include "AudioParam.h" 12 #include "mozilla/dom/ConstantSourceNodeBinding.h" 13 14 namespace mozilla { 15 namespace dom { 16 17 class AudioContext; 18 19 class ConstantSourceNode final : public AudioScheduledSourceNode, 20 public MainThreadMediaTrackListener { 21 public: 22 explicit ConstantSourceNode(AudioContext* aContext); 23 24 NS_DECL_ISUPPORTS_INHERITED 25 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ConstantSourceNode, 26 AudioScheduledSourceNode) 27 28 JSObject* WrapObject(JSContext* aCx, 29 JS::Handle<JSObject*> aGivenProto) override; 30 31 static already_AddRefed<ConstantSourceNode> Constructor( 32 const GlobalObject& aGlobal, AudioContext& aContext, 33 const ConstantSourceOptions& aOptions); 34 35 void DestroyMediaTrack() override; 36 NumberOfInputs()37 uint16_t NumberOfInputs() const final { return 0; } 38 Offset()39 AudioParam* Offset() const { return mOffset; } 40 41 void Start(double aWhen, ErrorResult& rv) override; 42 void Stop(double aWhen, ErrorResult& rv) override; 43 44 void NotifyMainThreadTrackEnded() override; 45 NodeType()46 const char* NodeType() const override { return "ConstantSourceNode"; } 47 48 size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const override; 49 size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override; 50 51 protected: 52 virtual ~ConstantSourceNode(); 53 54 private: 55 RefPtr<AudioParam> mOffset; 56 bool mStartCalled; 57 }; 58 59 } // namespace dom 60 } // namespace mozilla 61 62 #endif 63