tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

StereoPannerNode.h (2425B)


      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 StereoPannerNode_h_
      8 #define StereoPannerNode_h_
      9 
     10 #include "AudioNode.h"
     11 #include "mozilla/RefCounted.h"
     12 #include "mozilla/dom/StereoPannerNodeBinding.h"
     13 #include "nsPrintfCString.h"
     14 
     15 namespace mozilla::dom {
     16 
     17 class AudioContext;
     18 struct StereoPannerOptions;
     19 
     20 class StereoPannerNode final : public AudioNode {
     21 public:
     22  static already_AddRefed<StereoPannerNode> Create(
     23      AudioContext& aAudioContext, const StereoPannerOptions& aOptions,
     24      ErrorResult& aRv);
     25 
     26  MOZ_DECLARE_REFCOUNTED_TYPENAME(StereoPannerNode)
     27 
     28  static already_AddRefed<StereoPannerNode> Constructor(
     29      const GlobalObject& aGlobal, AudioContext& aAudioContext,
     30      const StereoPannerOptions& aOptions, ErrorResult& aRv) {
     31    return Create(aAudioContext, aOptions, aRv);
     32  }
     33 
     34  virtual JSObject* WrapObject(JSContext* aCx,
     35                               JS::Handle<JSObject*> aGivenProto) override;
     36 
     37  virtual void SetChannelCount(uint32_t aChannelCount,
     38                               ErrorResult& aRv) override {
     39    if (aChannelCount > 2) {
     40      aRv.ThrowNotSupportedError(
     41          nsPrintfCString("%u is greater than 2", aChannelCount));
     42      return;
     43    }
     44    AudioNode::SetChannelCount(aChannelCount, aRv);
     45  }
     46  virtual void SetChannelCountModeValue(ChannelCountMode aMode,
     47                                        ErrorResult& aRv) override {
     48    if (aMode == ChannelCountMode::Max) {
     49      aRv.ThrowNotSupportedError("Cannot set channel count mode to \"max\"");
     50      return;
     51    }
     52    AudioNode::SetChannelCountModeValue(aMode, aRv);
     53  }
     54 
     55  AudioParam* Pan() const { return mPan; }
     56 
     57  NS_DECL_ISUPPORTS_INHERITED
     58  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(StereoPannerNode, AudioNode)
     59 
     60  virtual const char* NodeType() const override { return "StereoPannerNode"; }
     61 
     62  virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const override;
     63  virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override;
     64 
     65 private:
     66  explicit StereoPannerNode(AudioContext* aContext);
     67  ~StereoPannerNode() = default;
     68 
     69  RefPtr<AudioParam> mPan;
     70 };
     71 
     72 }  // namespace mozilla::dom
     73 
     74 #endif