PeriodicWave.h (1899B)
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 PeriodicWave_h_ 8 #define PeriodicWave_h_ 9 10 #include "AudioContext.h" 11 #include "AudioNodeEngine.h" 12 #include "nsCycleCollectionParticipant.h" 13 #include "nsWrapperCache.h" 14 15 namespace mozilla::dom { 16 17 class AudioContext; 18 struct PeriodicWaveOptions; 19 20 class PeriodicWave final : public nsWrapperCache { 21 public: 22 PeriodicWave(AudioContext* aContext, const float* aRealData, 23 const uint32_t aRealSize, const float* aImagData, 24 const uint32_t aImagSize, const bool aDisableNormalization, 25 ErrorResult& aRv); 26 27 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(PeriodicWave) 28 NS_DECL_CYCLE_COLLECTION_NATIVE_WRAPPERCACHE_CLASS(PeriodicWave) 29 30 static already_AddRefed<PeriodicWave> Constructor( 31 const GlobalObject& aGlobal, AudioContext& aAudioContext, 32 const PeriodicWaveOptions& aOptions, ErrorResult& aRv); 33 34 AudioContext* GetParentObject() const { return mContext; } 35 36 JSObject* WrapObject(JSContext* aCx, 37 JS::Handle<JSObject*> aGivenProto) override; 38 39 uint32_t DataLength() const { return mCoefficients.mDuration; } 40 41 bool DisableNormalization() const { return mDisableNormalization; } 42 43 const AudioChunk& GetThreadSharedBuffer() const { return mCoefficients; } 44 45 size_t SizeOfExcludingThisIfNotShared(MallocSizeOf aMallocSizeOf) const; 46 size_t SizeOfIncludingThisIfNotShared(MallocSizeOf aMallocSizeOf) const; 47 48 private: 49 ~PeriodicWave() = default; 50 51 AudioChunk mCoefficients; 52 RefPtr<AudioContext> mContext; 53 bool mDisableNormalization; 54 }; 55 56 } // namespace mozilla::dom 57 58 #endif