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