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