Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/AudioParam.h

Issue 1865583002: Implement BaseAudioContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 13 matching lines...) Expand all
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #ifndef AudioParam_h 29 #ifndef AudioParam_h
30 #define AudioParam_h 30 #define AudioParam_h
31 31
32 #include "bindings/core/v8/ScriptWrappable.h" 32 #include "bindings/core/v8/ScriptWrappable.h"
33 #include "core/dom/DOMTypedArray.h" 33 #include "core/dom/DOMTypedArray.h"
34 #include "modules/webaudio/AbstractAudioContext.h"
35 #include "modules/webaudio/AudioParamTimeline.h" 34 #include "modules/webaudio/AudioParamTimeline.h"
36 #include "modules/webaudio/AudioSummingJunction.h" 35 #include "modules/webaudio/AudioSummingJunction.h"
36 #include "modules/webaudio/BaseAudioContext.h"
37 #include "wtf/PassRefPtr.h" 37 #include "wtf/PassRefPtr.h"
38 #include "wtf/text/WTFString.h" 38 #include "wtf/text/WTFString.h"
39 #include <sys/types.h> 39 #include <sys/types.h>
40 40
41 namespace blink { 41 namespace blink {
42 42
43 class AudioNodeOutput; 43 class AudioNodeOutput;
44 44
45 // AudioParamHandler is an actual implementation of web-exposed AudioParam 45 // AudioParamHandler is an actual implementation of web-exposed AudioParam
46 // interface. Each of AudioParam object creates and owns an AudioParamHandler, 46 // interface. Each of AudioParam object creates and owns an AudioParamHandler,
47 // and it is responsible for all of AudioParam tasks. An AudioParamHandler 47 // and it is responsible for all of AudioParam tasks. An AudioParamHandler
48 // object is owned by the originator AudioParam object, and some audio 48 // object is owned by the originator AudioParam object, and some audio
49 // processing classes have additional references. An AudioParamHandler can 49 // processing classes have additional references. An AudioParamHandler can
50 // outlive the owner AudioParam, and it never dies before the owner AudioParam 50 // outlive the owner AudioParam, and it never dies before the owner AudioParam
51 // dies. 51 // dies.
52 class AudioParamHandler final : public ThreadSafeRefCounted<AudioParamHandler>, public AudioSummingJunction { 52 class AudioParamHandler final : public ThreadSafeRefCounted<AudioParamHandler>, public AudioSummingJunction {
53 public: 53 public:
54 static const double DefaultSmoothingConstant; 54 static const double DefaultSmoothingConstant;
55 static const double SnapThreshold; 55 static const double SnapThreshold;
56 56
57 static PassRefPtr<AudioParamHandler> create(AbstractAudioContext& context, d ouble defaultValue) 57 static PassRefPtr<AudioParamHandler> create(BaseAudioContext& context, doubl e defaultValue)
58 { 58 {
59 return adoptRef(new AudioParamHandler(context, defaultValue)); 59 return adoptRef(new AudioParamHandler(context, defaultValue));
60 } 60 }
61 61
62 // This should be used only in audio rendering thread. 62 // This should be used only in audio rendering thread.
63 AbstractAudioContext* context() const; 63 BaseAudioContext* context() const;
64 64
65 // AudioSummingJunction 65 // AudioSummingJunction
66 void didUpdate() override { } 66 void didUpdate() override { }
67 67
68 AudioParamTimeline& timeline() { return m_timeline; } 68 AudioParamTimeline& timeline() { return m_timeline; }
69 69
70 // Intrinsic value. 70 // Intrinsic value.
71 float value(); 71 float value();
72 void setValue(float); 72 void setValue(float);
73 73
(...skipping 19 matching lines...) Expand all
93 93
94 // Calculates numberOfValues parameter values starting at the context's curr ent time. 94 // Calculates numberOfValues parameter values starting at the context's curr ent time.
95 // Must be called in the context's render thread. 95 // Must be called in the context's render thread.
96 void calculateSampleAccurateValues(float* values, unsigned numberOfValues); 96 void calculateSampleAccurateValues(float* values, unsigned numberOfValues);
97 97
98 // Connect an audio-rate signal to control this parameter. 98 // Connect an audio-rate signal to control this parameter.
99 void connect(AudioNodeOutput&); 99 void connect(AudioNodeOutput&);
100 void disconnect(AudioNodeOutput&); 100 void disconnect(AudioNodeOutput&);
101 101
102 private: 102 private:
103 AudioParamHandler(AbstractAudioContext& context, double defaultValue) 103 AudioParamHandler(BaseAudioContext& context, double defaultValue)
104 : AudioSummingJunction(context.deferredTaskHandler()) 104 : AudioSummingJunction(context.deferredTaskHandler())
105 , m_intrinsicValue(defaultValue) 105 , m_intrinsicValue(defaultValue)
106 , m_defaultValue(defaultValue) 106 , m_defaultValue(defaultValue)
107 , m_smoothedValue(defaultValue) 107 , m_smoothedValue(defaultValue)
108 , m_context(&context) { } 108 , m_context(&context) { }
109 109
110 // sampleAccurate corresponds to a-rate (audio rate) vs. k-rate in the Web A udio specification. 110 // sampleAccurate corresponds to a-rate (audio rate) vs. k-rate in the Web A udio specification.
111 void calculateFinalValues(float* values, unsigned numberOfValues, bool sampl eAccurate); 111 void calculateFinalValues(float* values, unsigned numberOfValues, bool sampl eAccurate);
112 void calculateTimelineValues(float* values, unsigned numberOfValues); 112 void calculateTimelineValues(float* values, unsigned numberOfValues);
113 113
114 // Intrinsic value 114 // Intrinsic value
115 float m_intrinsicValue; 115 float m_intrinsicValue;
116 float intrinsicValue() const { return noBarrierLoad(&m_intrinsicValue); } 116 float intrinsicValue() const { return noBarrierLoad(&m_intrinsicValue); }
117 void setIntrinsicValue(float newValue) { noBarrierStore(&m_intrinsicValue, n ewValue); } 117 void setIntrinsicValue(float newValue) { noBarrierStore(&m_intrinsicValue, n ewValue); }
118 118
119 float m_defaultValue; 119 float m_defaultValue;
120 120
121 // Smoothing (de-zippering) 121 // Smoothing (de-zippering)
122 float m_smoothedValue; 122 float m_smoothedValue;
123 123
124 AudioParamTimeline m_timeline; 124 AudioParamTimeline m_timeline;
125 125
126 // We can't make this Persistent because of a reference cycle. It's safe to 126 // We can't make this Persistent because of a reference cycle. It's safe to
127 // access this field only when we're rendering audio. 127 // access this field only when we're rendering audio.
128 UntracedMember<AbstractAudioContext> m_context; 128 UntracedMember<BaseAudioContext> m_context;
129 }; 129 };
130 130
131 // AudioParam class represents web-exposed AudioParam interface. 131 // AudioParam class represents web-exposed AudioParam interface.
132 class AudioParam final : public GarbageCollectedFinalized<AudioParam>, public Sc riptWrappable { 132 class AudioParam final : public GarbageCollectedFinalized<AudioParam>, public Sc riptWrappable {
133 DEFINE_WRAPPERTYPEINFO(); 133 DEFINE_WRAPPERTYPEINFO();
134 public: 134 public:
135 static AudioParam* create(AbstractAudioContext&, double defaultValue); 135 static AudioParam* create(BaseAudioContext&, double defaultValue);
136 DECLARE_TRACE(); 136 DECLARE_TRACE();
137 // |handler| always returns a valid object. 137 // |handler| always returns a valid object.
138 AudioParamHandler& handler() const { return *m_handler; } 138 AudioParamHandler& handler() const { return *m_handler; }
139 // |context| always returns a valid object. 139 // |context| always returns a valid object.
140 AbstractAudioContext* context() const { return m_context; } 140 BaseAudioContext* context() const { return m_context; }
141 141
142 float value() const; 142 float value() const;
143 void setValue(float); 143 void setValue(float);
144 float defaultValue() const; 144 float defaultValue() const;
145 AudioParam* setValueAtTime(float value, double time, ExceptionState&); 145 AudioParam* setValueAtTime(float value, double time, ExceptionState&);
146 AudioParam* linearRampToValueAtTime(float value, double time, ExceptionState &); 146 AudioParam* linearRampToValueAtTime(float value, double time, ExceptionState &);
147 AudioParam* exponentialRampToValueAtTime(float value, double time, Exception State&); 147 AudioParam* exponentialRampToValueAtTime(float value, double time, Exception State&);
148 AudioParam* setTargetAtTime(float target, double time, double timeConstant, ExceptionState&); 148 AudioParam* setTargetAtTime(float target, double time, double timeConstant, ExceptionState&);
149 AudioParam* setValueCurveAtTime(DOMFloat32Array* curve, double time, double duration, ExceptionState&); 149 AudioParam* setValueCurveAtTime(DOMFloat32Array* curve, double time, double duration, ExceptionState&);
150 AudioParam* cancelScheduledValues(double startTime, ExceptionState&); 150 AudioParam* cancelScheduledValues(double startTime, ExceptionState&);
151 151
152 private: 152 private:
153 AudioParam(AbstractAudioContext&, double defaultValue); 153 AudioParam(BaseAudioContext&, double defaultValue);
154 154
155 RefPtr<AudioParamHandler> m_handler; 155 RefPtr<AudioParamHandler> m_handler;
156 Member<AbstractAudioContext> m_context; 156 Member<BaseAudioContext> m_context;
157 }; 157 };
158 158
159 } // namespace blink 159 } // namespace blink
160 160
161 #endif // AudioParam_h 161 #endif // AudioParam_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698