Line data Source code
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 : {
25 : public:
26 : PeriodicWave(AudioContext* aContext,
27 : const float* aRealData,
28 : const float* aImagData,
29 : const uint32_t aLength,
30 : const bool aDisableNormalization,
31 : ErrorResult& aRv);
32 :
33 0 : NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(PeriodicWave)
34 0 : NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(PeriodicWave)
35 :
36 : static already_AddRefed<PeriodicWave>
37 : Constructor(const GlobalObject& aGlobal, AudioContext& aAudioContext,
38 : const PeriodicWaveOptions& aOptions, ErrorResult& aRv);
39 :
40 0 : AudioContext* GetParentObject() const
41 : {
42 0 : return mContext;
43 : }
44 :
45 : JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
46 :
47 0 : uint32_t DataLength() const
48 : {
49 0 : return mLength;
50 : }
51 :
52 0 : bool DisableNormalization() const
53 : {
54 0 : return mDisableNormalization;
55 : }
56 :
57 0 : ThreadSharedFloatArrayBufferList* GetThreadSharedBuffer() const
58 : {
59 0 : return mCoefficients;
60 : }
61 :
62 : size_t SizeOfExcludingThisIfNotShared(MallocSizeOf aMallocSizeOf) const;
63 : size_t SizeOfIncludingThisIfNotShared(MallocSizeOf aMallocSizeOf) const;
64 :
65 : private:
66 0 : ~PeriodicWave() = default;
67 :
68 : RefPtr<AudioContext> mContext;
69 : RefPtr<ThreadSharedFloatArrayBufferList> mCoefficients;
70 : uint32_t mLength;
71 : bool mDisableNormalization;
72 : };
73 :
74 : } // namespace dom
75 : } // namespace mozilla
76 :
77 : #endif
|