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 ChannelMergerNode_h_ 8 #define ChannelMergerNode_h_ 9 10 #include "AudioNode.h" 11 12 namespace mozilla { 13 namespace dom { 14 15 class AudioContext; 16 struct ChannelMergerOptions; 17 18 class ChannelMergerNode final : public AudioNode { 19 public: 20 static already_AddRefed<ChannelMergerNode> Create( 21 AudioContext& aAudioContext, const ChannelMergerOptions& aOptions, 22 ErrorResult& aRv); 23 NS_INLINE_DECL_REFCOUNTING_INHERITED(ChannelMergerNode,AudioNode)24 NS_INLINE_DECL_REFCOUNTING_INHERITED(ChannelMergerNode, AudioNode) 25 26 static already_AddRefed<ChannelMergerNode> Constructor( 27 const GlobalObject& aGlobal, AudioContext& aAudioContext, 28 const ChannelMergerOptions& aOptions, ErrorResult& aRv) { 29 return Create(aAudioContext, aOptions, aRv); 30 } 31 32 JSObject* WrapObject(JSContext* aCx, 33 JS::Handle<JSObject*> aGivenProto) override; 34 NumberOfInputs()35 uint16_t NumberOfInputs() const override { return mInputCount; } 36 NodeType()37 const char* NodeType() const override { return "ChannelMergerNode"; } 38 SetChannelCount(uint32_t aChannelCount,ErrorResult & aRv)39 virtual void SetChannelCount(uint32_t aChannelCount, 40 ErrorResult& aRv) override { 41 if (aChannelCount != 1) { 42 aRv.ThrowInvalidStateError( 43 "Cannot change channel count of ChannelMergerNode"); 44 } 45 } 46 SetChannelCountModeValue(ChannelCountMode aMode,ErrorResult & aRv)47 virtual void SetChannelCountModeValue(ChannelCountMode aMode, 48 ErrorResult& aRv) override { 49 if (aMode != ChannelCountMode::Explicit) { 50 aRv.ThrowInvalidStateError( 51 "Cannot change channel count mode of ChannelMergerNode"); 52 } 53 } 54 SizeOfIncludingThis(MallocSizeOf aMallocSizeOf)55 size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override { 56 return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); 57 } 58 59 private: 60 ChannelMergerNode(AudioContext* aContext, uint16_t aInputCount); 61 ~ChannelMergerNode() = default; 62 63 const uint16_t mInputCount; 64 }; 65 66 } // namespace dom 67 } // namespace mozilla 68 69 #endif 70