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