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

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

Issue 1037683002: Web Audio: Unapply Oilpan to AudioSummingJunction. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove m_didCallDispose Created 5 years, 9 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/AudioParam.h ('k') | Source/modules/webaudio/AudioSummingJunction.h » ('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 23 matching lines...) Expand all
34 #include "wtf/MathExtras.h" 34 #include "wtf/MathExtras.h"
35 35
36 namespace blink { 36 namespace blink {
37 37
38 const double AudioParamHandler::DefaultSmoothingConstant = 0.05; 38 const double AudioParamHandler::DefaultSmoothingConstant = 0.05;
39 const double AudioParamHandler::SnapThreshold = 0.001; 39 const double AudioParamHandler::SnapThreshold = 0.001;
40 40
41 float AudioParamHandler::value() 41 float AudioParamHandler::value()
42 { 42 {
43 // Update value for timeline. 43 // Update value for timeline.
44 if (context() && context()->isAudioThread()) { 44 if (deferredTaskHandler().isAudioThread()) {
45 bool hasValue; 45 bool hasValue;
46 float timelineValue = m_timeline.valueForContextTime(context(), narrowPr ecisionToFloat(m_value), hasValue); 46 float timelineValue = m_timeline.valueForContextTime(context(), narrowPr ecisionToFloat(m_value), hasValue);
47 47
48 if (hasValue) 48 if (hasValue)
49 m_value = timelineValue; 49 m_value = timelineValue;
50 } 50 }
51 51
52 return narrowPrecisionToFloat(m_value); 52 return narrowPrecisionToFloat(m_value);
53 } 53 }
54 54
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 93
94 float AudioParamHandler::finalValue() 94 float AudioParamHandler::finalValue()
95 { 95 {
96 float value = m_value; 96 float value = m_value;
97 calculateFinalValues(&value, 1, false); 97 calculateFinalValues(&value, 1, false);
98 return value; 98 return value;
99 } 99 }
100 100
101 void AudioParamHandler::calculateSampleAccurateValues(float* values, unsigned nu mberOfValues) 101 void AudioParamHandler::calculateSampleAccurateValues(float* values, unsigned nu mberOfValues)
102 { 102 {
103 bool isSafe = context() && context()->isAudioThread() && values && numberOfV alues; 103 bool isSafe = deferredTaskHandler().isAudioThread() && values && numberOfVal ues;
104 ASSERT(isSafe); 104 ASSERT(isSafe);
105 if (!isSafe) 105 if (!isSafe)
106 return; 106 return;
107 107
108 calculateFinalValues(values, numberOfValues, true); 108 calculateFinalValues(values, numberOfValues, true);
109 } 109 }
110 110
111 void AudioParamHandler::calculateFinalValues(float* values, unsigned numberOfVal ues, bool sampleAccurate) 111 void AudioParamHandler::calculateFinalValues(float* values, unsigned numberOfVal ues, bool sampleAccurate)
112 { 112 {
113 bool isGood = context() && context()->isAudioThread() && values && numberOfV alues; 113 bool isGood = deferredTaskHandler().isAudioThread() && values && numberOfVal ues;
114 ASSERT(isGood); 114 ASSERT(isGood);
115 if (!isGood) 115 if (!isGood)
116 return; 116 return;
117 117
118 // The calculated result will be the "intrinsic" value summed with all audio -rate connections. 118 // The calculated result will be the "intrinsic" value summed with all audio -rate connections.
119 119
120 if (sampleAccurate) { 120 if (sampleAccurate) {
121 // Calculate sample-accurate (a-rate) intrinsic values. 121 // Calculate sample-accurate (a-rate) intrinsic values.
122 calculateTimelineValues(values, numberOfValues); 122 calculateTimelineValues(values, numberOfValues);
123 } else { 123 } else {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 double startTime = context()->currentTime(); 156 double startTime = context()->currentTime();
157 double endTime = startTime + numberOfValues / sampleRate; 157 double endTime = startTime + numberOfValues / sampleRate;
158 158
159 // Note we're running control rate at the sample-rate. 159 // Note we're running control rate at the sample-rate.
160 // Pass in the current value as default value. 160 // Pass in the current value as default value.
161 m_value = m_timeline.valuesForTimeRange(startTime, endTime, narrowPrecisionT oFloat(m_value), values, numberOfValues, sampleRate, sampleRate); 161 m_value = m_timeline.valuesForTimeRange(startTime, endTime, narrowPrecisionT oFloat(m_value), values, numberOfValues, sampleRate, sampleRate);
162 } 162 }
163 163
164 void AudioParamHandler::connect(AudioNodeOutput& output) 164 void AudioParamHandler::connect(AudioNodeOutput& output)
165 { 165 {
166 ASSERT(context()->isGraphOwner()); 166 ASSERT(deferredTaskHandler().isGraphOwner());
167 167
168 if (m_outputs.contains(&output)) 168 if (m_outputs.contains(&output))
169 return; 169 return;
170 170
171 output.addParam(*this); 171 output.addParam(*this);
172 m_outputs.add(&output); 172 m_outputs.add(&output);
173 changedOutputs(); 173 changedOutputs();
174 } 174 }
175 175
176 void AudioParamHandler::disconnect(AudioNodeOutput& output) 176 void AudioParamHandler::disconnect(AudioNodeOutput& output)
177 { 177 {
178 ASSERT(context()->isGraphOwner()); 178 ASSERT(deferredTaskHandler().isGraphOwner());
179 179
180 if (m_outputs.contains(&output)) { 180 if (m_outputs.contains(&output)) {
181 m_outputs.remove(&output); 181 m_outputs.remove(&output);
182 changedOutputs(); 182 changedOutputs();
183 output.removeParam(*this); 183 output.removeParam(*this);
184 } 184 }
185 } 185 }
186 186
187 DEFINE_TRACE(AudioParamHandler)
188 {
189 visitor->trace(m_context);
190 // TODO(tkent): Oilpan: m_renderingOutputs should not be strong references.
191 // This is a short-term workaround to avoid crashes, and causes AudioNode
192 // leaks.
193 AudioContext::AutoLocker locker(deferredTaskHandler());
194 for (size_t i = 0; i < m_renderingOutputs.size(); ++i)
195 visitor->trace(m_renderingOutputs[i]);
196 }
197
187 } // namespace blink 198 } // namespace blink
188 199
189 #endif // ENABLE(WEB_AUDIO) 200 #endif // ENABLE(WEB_AUDIO)
OLDNEW
« no previous file with comments | « Source/modules/webaudio/AudioParam.h ('k') | Source/modules/webaudio/AudioSummingJunction.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698