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

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

Issue 1214463003: Split "Online" and "Offline" AudioContext processing (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Bring to ToT Created 5 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « Source/modules/webaudio/AudioNodeOutput.cpp ('k') | Source/modules/webaudio/AudioParam.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/AudioContext.h" 34 #include "modules/webaudio/AbstractAudioContext.h"
35 #include "modules/webaudio/AudioParamTimeline.h" 35 #include "modules/webaudio/AudioParamTimeline.h"
36 #include "modules/webaudio/AudioSummingJunction.h" 36 #include "modules/webaudio/AudioSummingJunction.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(AudioContext& context, double de faultValue) 57 static PassRefPtr<AudioParamHandler> create(AbstractAudioContext& context, d ouble defaultValue)
58 { 58 {
59 return adoptRef(new AudioParamHandler(context, defaultValue)); 59 return adoptRef(new AudioParamHandler(context, defaultValue));
60 } 60 }
61 DECLARE_TRACE(); 61 DECLARE_TRACE();
62 // This should be used only in audio rendering thread. 62 // This should be used only in audio rendering thread.
63 AudioContext* context() const; 63 AbstractAudioContext* 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(AudioContext& context, double defaultValue) 103 AudioParamHandler(AbstractAudioContext& context, double defaultValue)
104 : AudioSummingJunction(context.deferredTaskHandler()) 104 : AudioSummingJunction(context.deferredTaskHandler())
105 , m_value(defaultValue) 105 , m_value(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 double m_value; 114 double m_value;
115 double m_defaultValue; 115 double m_defaultValue;
116 116
117 // Smoothing (de-zippering) 117 // Smoothing (de-zippering)
118 double m_smoothedValue; 118 double m_smoothedValue;
119 119
120 AudioParamTimeline m_timeline; 120 AudioParamTimeline m_timeline;
121 121
122 // We can't make this Persistent because of a reference cycle. It's safe to 122 // We can't make this Persistent because of a reference cycle. It's safe to
123 // access this field only when we're rendering audio. 123 // access this field only when we're rendering audio.
124 AudioContext& m_context; 124 AbstractAudioContext& m_context;
125 }; 125 };
126 126
127 // AudioParam class represents web-exposed AudioParam interface. 127 // AudioParam class represents web-exposed AudioParam interface.
128 class AudioParam final : public GarbageCollectedFinalized<AudioParam>, public Sc riptWrappable { 128 class AudioParam final : public GarbageCollectedFinalized<AudioParam>, public Sc riptWrappable {
129 DEFINE_WRAPPERTYPEINFO(); 129 DEFINE_WRAPPERTYPEINFO();
130 public: 130 public:
131 static AudioParam* create(AudioContext&, double defaultValue); 131 static AudioParam* create(AbstractAudioContext&, double defaultValue);
132 DECLARE_TRACE(); 132 DECLARE_TRACE();
133 // |handler| always returns a valid object. 133 // |handler| always returns a valid object.
134 AudioParamHandler& handler() const { return *m_handler; } 134 AudioParamHandler& handler() const { return *m_handler; }
135 // |context| always returns a valid object. 135 // |context| always returns a valid object.
136 AudioContext* context() const { return m_context; } 136 AbstractAudioContext* context() const { return m_context; }
137 137
138 float value() const; 138 float value() const;
139 void setValue(float); 139 void setValue(float);
140 float defaultValue() const; 140 float defaultValue() const;
141 void setValueAtTime(float value, double time, ExceptionState&); 141 void setValueAtTime(float value, double time, ExceptionState&);
142 void linearRampToValueAtTime(float value, double time, ExceptionState&); 142 void linearRampToValueAtTime(float value, double time, ExceptionState&);
143 void exponentialRampToValueAtTime(float value, double time, ExceptionState&) ; 143 void exponentialRampToValueAtTime(float value, double time, ExceptionState&) ;
144 void setTargetAtTime(float target, double time, double timeConstant, Excepti onState&); 144 void setTargetAtTime(float target, double time, double timeConstant, Excepti onState&);
145 void setValueCurveAtTime(DOMFloat32Array* curve, double time, double duratio n, ExceptionState&); 145 void setValueCurveAtTime(DOMFloat32Array* curve, double time, double duratio n, ExceptionState&);
146 void cancelScheduledValues(double startTime, ExceptionState&); 146 void cancelScheduledValues(double startTime, ExceptionState&);
147 147
148 private: 148 private:
149 AudioParam(AudioContext&, double defaultValue); 149 AudioParam(AbstractAudioContext&, double defaultValue);
150 150
151 RefPtr<AudioParamHandler> m_handler; 151 RefPtr<AudioParamHandler> m_handler;
152 Member<AudioContext> m_context; 152 Member<AbstractAudioContext> m_context;
153 }; 153 };
154 154
155 } // namespace blink 155 } // namespace blink
156 156
157 #endif // AudioParam_h 157 #endif // AudioParam_h
OLDNEW
« no previous file with comments | « Source/modules/webaudio/AudioNodeOutput.cpp ('k') | Source/modules/webaudio/AudioParam.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698