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

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

Issue 19724003: Revert "Transition modules/** to use ExceptionState" (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 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/AudioNode.h ('k') | Source/modules/webaudio/BiquadFilterNode.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 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 10 matching lines...) Expand all
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */ 23 */
24 24
25 #include "config.h" 25 #include "config.h"
26 26
27 #if ENABLE(WEB_AUDIO) 27 #if ENABLE(WEB_AUDIO)
28 28
29 #include "modules/webaudio/AudioNode.h" 29 #include "modules/webaudio/AudioNode.h"
30 30
31 #include "bindings/v8/ExceptionState.h"
32 #include "core/dom/ExceptionCode.h" 31 #include "core/dom/ExceptionCode.h"
33 #include "modules/webaudio/AudioContext.h" 32 #include "modules/webaudio/AudioContext.h"
34 #include "modules/webaudio/AudioNodeInput.h" 33 #include "modules/webaudio/AudioNodeInput.h"
35 #include "modules/webaudio/AudioNodeOutput.h" 34 #include "modules/webaudio/AudioNodeOutput.h"
36 #include "modules/webaudio/AudioParam.h" 35 #include "modules/webaudio/AudioParam.h"
37 #include "wtf/Atomics.h" 36 #include "wtf/Atomics.h"
38 #include "wtf/MainThread.h" 37 #include "wtf/MainThread.h"
39 38
40 #if DEBUG_AUDIONODE_REFERENCES 39 #if DEBUG_AUDIONODE_REFERENCES
41 #include <stdio.h> 40 #include <stdio.h>
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 return 0; 116 return 0;
118 } 117 }
119 118
120 AudioNodeOutput* AudioNode::output(unsigned i) 119 AudioNodeOutput* AudioNode::output(unsigned i)
121 { 120 {
122 if (i < m_outputs.size()) 121 if (i < m_outputs.size())
123 return m_outputs[i].get(); 122 return m_outputs[i].get();
124 return 0; 123 return 0;
125 } 124 }
126 125
127 void AudioNode::connect(AudioNode* destination, unsigned outputIndex, unsigned i nputIndex, ExceptionState& es) 126 void AudioNode::connect(AudioNode* destination, unsigned outputIndex, unsigned i nputIndex, ExceptionCode& ec)
128 { 127 {
129 ASSERT(isMainThread()); 128 ASSERT(isMainThread());
130 AudioContext::AutoLocker locker(context()); 129 AudioContext::AutoLocker locker(context());
131 130
132 if (!destination) { 131 if (!destination) {
133 es.throwDOMException(SyntaxError); 132 ec = SyntaxError;
134 return; 133 return;
135 } 134 }
136 135
137 // Sanity check input and output indices. 136 // Sanity check input and output indices.
138 if (outputIndex >= numberOfOutputs()) { 137 if (outputIndex >= numberOfOutputs()) {
139 es.throwDOMException(IndexSizeError); 138 ec = IndexSizeError;
140 return; 139 return;
141 } 140 }
142 141
143 if (destination && inputIndex >= destination->numberOfInputs()) { 142 if (destination && inputIndex >= destination->numberOfInputs()) {
144 es.throwDOMException(IndexSizeError); 143 ec = IndexSizeError;
145 return; 144 return;
146 } 145 }
147 146
148 if (context() != destination->context()) { 147 if (context() != destination->context()) {
149 es.throwDOMException(SyntaxError); 148 ec = SyntaxError;
150 return; 149 return;
151 } 150 }
152 151
153 AudioNodeInput* input = destination->input(inputIndex); 152 AudioNodeInput* input = destination->input(inputIndex);
154 AudioNodeOutput* output = this->output(outputIndex); 153 AudioNodeOutput* output = this->output(outputIndex);
155 input->connect(output); 154 input->connect(output);
156 155
157 // Let context know that a connection has been made. 156 // Let context know that a connection has been made.
158 context()->incrementConnectionCount(); 157 context()->incrementConnectionCount();
159 } 158 }
160 159
161 void AudioNode::connect(AudioParam* param, unsigned outputIndex, ExceptionState& es) 160 void AudioNode::connect(AudioParam* param, unsigned outputIndex, ExceptionCode& ec)
162 { 161 {
163 ASSERT(isMainThread()); 162 ASSERT(isMainThread());
164 AudioContext::AutoLocker locker(context()); 163 AudioContext::AutoLocker locker(context());
165 164
166 if (!param) { 165 if (!param) {
167 es.throwDOMException(SyntaxError); 166 ec = SyntaxError;
168 return; 167 return;
169 } 168 }
170 169
171 if (outputIndex >= numberOfOutputs()) { 170 if (outputIndex >= numberOfOutputs()) {
172 es.throwDOMException(IndexSizeError); 171 ec = IndexSizeError;
173 return; 172 return;
174 } 173 }
175 174
176 if (context() != param->context()) { 175 if (context() != param->context()) {
177 es.throwDOMException(SyntaxError); 176 ec = SyntaxError;
178 return; 177 return;
179 } 178 }
180 179
181 AudioNodeOutput* output = this->output(outputIndex); 180 AudioNodeOutput* output = this->output(outputIndex);
182 param->connect(output); 181 param->connect(output);
183 } 182 }
184 183
185 void AudioNode::disconnect(unsigned outputIndex, ExceptionState& es) 184 void AudioNode::disconnect(unsigned outputIndex, ExceptionCode& ec)
186 { 185 {
187 ASSERT(isMainThread()); 186 ASSERT(isMainThread());
188 AudioContext::AutoLocker locker(context()); 187 AudioContext::AutoLocker locker(context());
189 188
190 // Sanity check input and output indices. 189 // Sanity check input and output indices.
191 if (outputIndex >= numberOfOutputs()) { 190 if (outputIndex >= numberOfOutputs()) {
192 es.throwDOMException(IndexSizeError); 191 ec = IndexSizeError;
193 return; 192 return;
194 } 193 }
195 194
196 AudioNodeOutput* output = this->output(outputIndex); 195 AudioNodeOutput* output = this->output(outputIndex);
197 output->disconnectAll(); 196 output->disconnectAll();
198 } 197 }
199 198
200 unsigned long AudioNode::channelCount() 199 unsigned long AudioNode::channelCount()
201 { 200 {
202 return m_channelCount; 201 return m_channelCount;
203 } 202 }
204 203
205 void AudioNode::setChannelCount(unsigned long channelCount, ExceptionState& es) 204 void AudioNode::setChannelCount(unsigned long channelCount, ExceptionCode& ec)
206 { 205 {
207 ASSERT(isMainThread()); 206 ASSERT(isMainThread());
208 AudioContext::AutoLocker locker(context()); 207 AudioContext::AutoLocker locker(context());
209 208
210 if (channelCount > 0 && channelCount <= AudioContext::maxNumberOfChannels()) { 209 if (channelCount > 0 && channelCount <= AudioContext::maxNumberOfChannels()) {
211 if (m_channelCount != channelCount) { 210 if (m_channelCount != channelCount) {
212 m_channelCount = channelCount; 211 m_channelCount = channelCount;
213 if (m_channelCountMode != Max) 212 if (m_channelCountMode != Max)
214 updateChannelsForInputs(); 213 updateChannelsForInputs();
215 } 214 }
216 } else { 215 } else {
217 es.throwDOMException(InvalidStateError); 216 ec = InvalidStateError;
218 } 217 }
219 } 218 }
220 219
221 String AudioNode::channelCountMode() 220 String AudioNode::channelCountMode()
222 { 221 {
223 switch (m_channelCountMode) { 222 switch (m_channelCountMode) {
224 case Max: 223 case Max:
225 return "max"; 224 return "max";
226 case ClampedMax: 225 case ClampedMax:
227 return "clamped-max"; 226 return "clamped-max";
228 case Explicit: 227 case Explicit:
229 return "explicit"; 228 return "explicit";
230 } 229 }
231 ASSERT_NOT_REACHED(); 230 ASSERT_NOT_REACHED();
232 return ""; 231 return "";
233 } 232 }
234 233
235 void AudioNode::setChannelCountMode(const String& mode, ExceptionState& es) 234 void AudioNode::setChannelCountMode(const String& mode, ExceptionCode& ec)
236 { 235 {
237 ASSERT(isMainThread()); 236 ASSERT(isMainThread());
238 AudioContext::AutoLocker locker(context()); 237 AudioContext::AutoLocker locker(context());
239 238
240 ChannelCountMode oldMode = m_channelCountMode; 239 ChannelCountMode oldMode = m_channelCountMode;
241 240
242 if (mode == "max") 241 if (mode == "max")
243 m_channelCountMode = Max; 242 m_channelCountMode = Max;
244 else if (mode == "clamped-max") 243 else if (mode == "clamped-max")
245 m_channelCountMode = ClampedMax; 244 m_channelCountMode = ClampedMax;
246 else if (mode == "explicit") 245 else if (mode == "explicit")
247 m_channelCountMode = Explicit; 246 m_channelCountMode = Explicit;
248 else 247 else
249 es.throwDOMException(InvalidStateError); 248 ec = InvalidStateError;
250 249
251 if (m_channelCountMode != oldMode) 250 if (m_channelCountMode != oldMode)
252 updateChannelsForInputs(); 251 updateChannelsForInputs();
253 } 252 }
254 253
255 String AudioNode::channelInterpretation() 254 String AudioNode::channelInterpretation()
256 { 255 {
257 switch (m_channelInterpretation) { 256 switch (m_channelInterpretation) {
258 case AudioBus::Speakers: 257 case AudioBus::Speakers:
259 return "speakers"; 258 return "speakers";
260 case AudioBus::Discrete: 259 case AudioBus::Discrete:
261 return "discrete"; 260 return "discrete";
262 } 261 }
263 ASSERT_NOT_REACHED(); 262 ASSERT_NOT_REACHED();
264 return ""; 263 return "";
265 } 264 }
266 265
267 void AudioNode::setChannelInterpretation(const String& interpretation, Exception State& es) 266 void AudioNode::setChannelInterpretation(const String& interpretation, Exception Code& ec)
268 { 267 {
269 ASSERT(isMainThread()); 268 ASSERT(isMainThread());
270 AudioContext::AutoLocker locker(context()); 269 AudioContext::AutoLocker locker(context());
271 270
272 if (interpretation == "speakers") 271 if (interpretation == "speakers")
273 m_channelInterpretation = AudioBus::Speakers; 272 m_channelInterpretation = AudioBus::Speakers;
274 else if (interpretation == "discrete") 273 else if (interpretation == "discrete")
275 m_channelInterpretation = AudioBus::Discrete; 274 m_channelInterpretation = AudioBus::Discrete;
276 else 275 else
277 es.throwDOMException(InvalidStateError); 276 ec = InvalidStateError;
278 } 277 }
279 278
280 void AudioNode::updateChannelsForInputs() 279 void AudioNode::updateChannelsForInputs()
281 { 280 {
282 for (unsigned i = 0; i < m_inputs.size(); ++i) 281 for (unsigned i = 0; i < m_inputs.size(); ++i)
283 input(i)->changedOutputs(); 282 input(i)->changedOutputs();
284 } 283 }
285 284
286 const AtomicString& AudioNode::interfaceName() const 285 const AtomicString& AudioNode::interfaceName() const
287 { 286 {
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 fprintf(stderr, "%d: %d\n", i, s_nodeCount[i]); 518 fprintf(stderr, "%d: %d\n", i, s_nodeCount[i]);
520 519
521 fprintf(stderr, "===========================\n\n\n"); 520 fprintf(stderr, "===========================\n\n\n");
522 } 521 }
523 522
524 #endif // DEBUG_AUDIONODE_REFERENCES 523 #endif // DEBUG_AUDIONODE_REFERENCES
525 524
526 } // namespace WebCore 525 } // namespace WebCore
527 526
528 #endif // ENABLE(WEB_AUDIO) 527 #endif // ENABLE(WEB_AUDIO)
OLDNEW
« no previous file with comments | « Source/modules/webaudio/AudioNode.h ('k') | Source/modules/webaudio/BiquadFilterNode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698