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

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

Issue 99083002: WIP: Migrate generated bindings to new ExceptionState constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase. Created 7 years 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 * 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/ExceptionMessages.h"
32 #include "bindings/v8/ExceptionState.h" 31 #include "bindings/v8/ExceptionState.h"
33 #include "core/dom/ExceptionCode.h" 32 #include "core/dom/ExceptionCode.h"
34 #include "modules/webaudio/AudioContext.h" 33 #include "modules/webaudio/AudioContext.h"
35 #include "modules/webaudio/AudioNodeInput.h" 34 #include "modules/webaudio/AudioNodeInput.h"
36 #include "modules/webaudio/AudioNodeOutput.h" 35 #include "modules/webaudio/AudioNodeOutput.h"
37 #include "modules/webaudio/AudioParam.h" 36 #include "modules/webaudio/AudioParam.h"
38 #include "wtf/Atomics.h" 37 #include "wtf/Atomics.h"
39 #include "wtf/MainThread.h" 38 #include "wtf/MainThread.h"
40 39
41 #if DEBUG_AUDIONODE_REFERENCES 40 #if DEBUG_AUDIONODE_REFERENCES
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } 170 }
172 171
173 void AudioNode::connect(AudioNode* destination, unsigned outputIndex, unsigned i nputIndex, ExceptionState& exceptionState) 172 void AudioNode::connect(AudioNode* destination, unsigned outputIndex, unsigned i nputIndex, ExceptionState& exceptionState)
174 { 173 {
175 ASSERT(isMainThread()); 174 ASSERT(isMainThread());
176 AudioContext::AutoLocker locker(context()); 175 AudioContext::AutoLocker locker(context());
177 176
178 if (!destination) { 177 if (!destination) {
179 exceptionState.throwDOMException( 178 exceptionState.throwDOMException(
180 SyntaxError, 179 SyntaxError,
181 ExceptionMessages::failedToExecute( 180 "invalid destination node.");
182 "connect",
183 "AudioNode",
184 "invalid destination node."));
185 return; 181 return;
186 } 182 }
187 183
188 // Sanity check input and output indices. 184 // Sanity check input and output indices.
189 if (outputIndex >= numberOfOutputs()) { 185 if (outputIndex >= numberOfOutputs()) {
190 exceptionState.throwDOMException( 186 exceptionState.throwDOMException(
191 IndexSizeError, 187 IndexSizeError,
192 ExceptionMessages::failedToExecute( 188 "output index (" + String::number(outputIndex) + ") exceeds number o f outputs (" + String::number(numberOfOutputs()) + ").");
193 "connect",
194 "AudioNode",
195 "output index (" + String::number(outputIndex) + ") exceeds numb er of outputs (" + String::number(numberOfOutputs()) + ")."));
196 return; 189 return;
197 } 190 }
198 191
199 if (destination && inputIndex >= destination->numberOfInputs()) { 192 if (destination && inputIndex >= destination->numberOfInputs()) {
200 exceptionState.throwDOMException( 193 exceptionState.throwDOMException(
201 IndexSizeError, 194 IndexSizeError,
202 ExceptionMessages::failedToExecute( 195 "input index (" + String::number(inputIndex) + ") exceeds number of inputs (" + String::number(destination->numberOfInputs()) + ").");
203 "connect",
204 "AudioNode",
205 "input index (" + String::number(inputIndex) + ") exceeds number of inputs (" + String::number(destination->numberOfInputs()) + ")."));
206 return; 196 return;
207 } 197 }
208 198
209 if (context() != destination->context()) { 199 if (context() != destination->context()) {
210 exceptionState.throwDOMException( 200 exceptionState.throwDOMException(
211 SyntaxError, 201 SyntaxError,
212 ExceptionMessages::failedToExecute( 202 "cannot connect to a destination belonging to a different audio cont ext.");
213 "connect",
214 "AudioNode",
215 "cannot connect to a destination belonging to a different audio context."));
216 return; 203 return;
217 } 204 }
218 205
219 AudioNodeInput* input = destination->input(inputIndex); 206 AudioNodeInput* input = destination->input(inputIndex);
220 AudioNodeOutput* output = this->output(outputIndex); 207 AudioNodeOutput* output = this->output(outputIndex);
221 input->connect(output); 208 input->connect(output);
222 209
223 // Let context know that a connection has been made. 210 // Let context know that a connection has been made.
224 context()->incrementConnectionCount(); 211 context()->incrementConnectionCount();
225 } 212 }
226 213
227 void AudioNode::connect(AudioParam* param, unsigned outputIndex, ExceptionState& exceptionState) 214 void AudioNode::connect(AudioParam* param, unsigned outputIndex, ExceptionState& exceptionState)
228 { 215 {
229 ASSERT(isMainThread()); 216 ASSERT(isMainThread());
230 AudioContext::AutoLocker locker(context()); 217 AudioContext::AutoLocker locker(context());
231 218
232 if (!param) { 219 if (!param) {
233 exceptionState.throwDOMException( 220 exceptionState.throwDOMException(
234 SyntaxError, 221 SyntaxError,
235 ExceptionMessages::failedToExecute( 222 "invalid AudioParam.");
236 "connect",
237 "AudioNode",
238 "invalid AudioParam."));
239 return; 223 return;
240 } 224 }
241 225
242 if (outputIndex >= numberOfOutputs()) { 226 if (outputIndex >= numberOfOutputs()) {
243 exceptionState.throwDOMException( 227 exceptionState.throwDOMException(
244 IndexSizeError, 228 IndexSizeError,
245 ExceptionMessages::failedToExecute( 229 "output index (" + String::number(outputIndex) + ") exceeds number o f outputs (" + String::number(numberOfOutputs()) + ").");
246 "connect",
247 "AudioNode",
248 "output index (" + String::number(outputIndex) + ") exceeds numb er of outputs (" + String::number(numberOfOutputs()) + ")."));
249 return; 230 return;
250 } 231 }
251 232
252 if (context() != param->context()) { 233 if (context() != param->context()) {
253 exceptionState.throwDOMException( 234 exceptionState.throwDOMException(
254 SyntaxError, 235 SyntaxError,
255 ExceptionMessages::failedToExecute( 236 "cannot connect to an AudioParam belonging to a different audio cont ext.");
256 "connect",
257 "AudioNode",
258 "cannot connect to an AudioParam belonging to a different audio context."));
259 return; 237 return;
260 } 238 }
261 239
262 AudioNodeOutput* output = this->output(outputIndex); 240 AudioNodeOutput* output = this->output(outputIndex);
263 param->connect(output); 241 param->connect(output);
264 } 242 }
265 243
266 void AudioNode::disconnect(unsigned outputIndex, ExceptionState& exceptionState) 244 void AudioNode::disconnect(unsigned outputIndex, ExceptionState& exceptionState)
267 { 245 {
268 ASSERT(isMainThread()); 246 ASSERT(isMainThread());
269 AudioContext::AutoLocker locker(context()); 247 AudioContext::AutoLocker locker(context());
270 248
271 // Sanity check input and output indices. 249 // Sanity check input and output indices.
272 if (outputIndex >= numberOfOutputs()) { 250 if (outputIndex >= numberOfOutputs()) {
273 exceptionState.throwDOMException( 251 exceptionState.throwDOMException(
274 IndexSizeError, 252 IndexSizeError,
275 ExceptionMessages::failedToExecute( 253 "output index (" + String::number(outputIndex) + ") exceeds number o f outputs (" + String::number(numberOfOutputs()) + ").");
276 "disconnect",
277 "AudioNode",
278 "output index (" + String::number(outputIndex) + ") exceeds numb er of outputs (" + String::number(numberOfOutputs()) + ")."));
279 return; 254 return;
280 } 255 }
281 256
282 AudioNodeOutput* output = this->output(outputIndex); 257 AudioNodeOutput* output = this->output(outputIndex);
283 output->disconnectAll(); 258 output->disconnectAll();
284 } 259 }
285 260
286 unsigned long AudioNode::channelCount() 261 unsigned long AudioNode::channelCount()
287 { 262 {
288 return m_channelCount; 263 return m_channelCount;
289 } 264 }
290 265
291 void AudioNode::setChannelCount(unsigned long channelCount, ExceptionState& exce ptionState) 266 void AudioNode::setChannelCount(unsigned long channelCount, ExceptionState& exce ptionState)
292 { 267 {
293 ASSERT(isMainThread()); 268 ASSERT(isMainThread());
294 AudioContext::AutoLocker locker(context()); 269 AudioContext::AutoLocker locker(context());
295 270
296 if (channelCount > 0 && channelCount <= AudioContext::maxNumberOfChannels()) { 271 if (channelCount > 0 && channelCount <= AudioContext::maxNumberOfChannels()) {
297 if (m_channelCount != channelCount) { 272 if (m_channelCount != channelCount) {
298 m_channelCount = channelCount; 273 m_channelCount = channelCount;
299 if (m_channelCountMode != Max) 274 if (m_channelCountMode != Max)
300 updateChannelsForInputs(); 275 updateChannelsForInputs();
301 } 276 }
302 } else { 277 } else {
303 exceptionState.throwDOMException( 278 exceptionState.throwDOMException(
304 NotSupportedError, 279 NotSupportedError,
305 ExceptionMessages::failedToSet( 280 "channel count (" + String::number(channelCount) + ") must be betwee n 1 and " + String::number(AudioContext::maxNumberOfChannels()) + ".");
306 "channelCount",
307 "AudioNode",
308 "channel count (" + String::number(channelCount)
309 + ") must be between 1 and "
310 + String::number(AudioContext::maxNumberOfChannels()) + "."));
311 } 281 }
312 } 282 }
313 283
314 String AudioNode::channelCountMode() 284 String AudioNode::channelCountMode()
315 { 285 {
316 switch (m_channelCountMode) { 286 switch (m_channelCountMode) {
317 case Max: 287 case Max:
318 return "max"; 288 return "max";
319 case ClampedMax: 289 case ClampedMax:
320 return "clamped-max"; 290 return "clamped-max";
(...skipping 13 matching lines...) Expand all
334 304
335 if (mode == "max") { 305 if (mode == "max") {
336 m_channelCountMode = Max; 306 m_channelCountMode = Max;
337 } else if (mode == "clamped-max") { 307 } else if (mode == "clamped-max") {
338 m_channelCountMode = ClampedMax; 308 m_channelCountMode = ClampedMax;
339 } else if (mode == "explicit") { 309 } else if (mode == "explicit") {
340 m_channelCountMode = Explicit; 310 m_channelCountMode = Explicit;
341 } else { 311 } else {
342 exceptionState.throwDOMException( 312 exceptionState.throwDOMException(
343 InvalidStateError, 313 InvalidStateError,
344 ExceptionMessages::failedToSet( 314 "invalid mode '" + mode + "'; must be 'max', 'clamped-max', or 'expl icit'.");
345 "channelCountMode",
346 "AudioNode",
347 "invalid mode '" + mode + "'; must be 'max', 'clamped-max', or ' explicit'."));
348 } 315 }
349 316
350 if (m_channelCountMode != oldMode) 317 if (m_channelCountMode != oldMode)
351 updateChannelsForInputs(); 318 updateChannelsForInputs();
352 } 319 }
353 320
354 String AudioNode::channelInterpretation() 321 String AudioNode::channelInterpretation()
355 { 322 {
356 switch (m_channelInterpretation) { 323 switch (m_channelInterpretation) {
357 case AudioBus::Speakers: 324 case AudioBus::Speakers:
(...skipping 10 matching lines...) Expand all
368 ASSERT(isMainThread()); 335 ASSERT(isMainThread());
369 AudioContext::AutoLocker locker(context()); 336 AudioContext::AutoLocker locker(context());
370 337
371 if (interpretation == "speakers") { 338 if (interpretation == "speakers") {
372 m_channelInterpretation = AudioBus::Speakers; 339 m_channelInterpretation = AudioBus::Speakers;
373 } else if (interpretation == "discrete") { 340 } else if (interpretation == "discrete") {
374 m_channelInterpretation = AudioBus::Discrete; 341 m_channelInterpretation = AudioBus::Discrete;
375 } else { 342 } else {
376 exceptionState.throwDOMException( 343 exceptionState.throwDOMException(
377 InvalidStateError, 344 InvalidStateError,
378 ExceptionMessages::failedToSet( 345 "invalid interpretation '" + interpretation + "'; must be 'speakers' or 'discrete'.");
379 "channelInterpretation",
380 "AudioNode",
381 "invalid interpretation '" + interpretation + "'; must be 'speak ers' or 'discrete'."));
382 } 346 }
383 } 347 }
384 348
385 void AudioNode::updateChannelsForInputs() 349 void AudioNode::updateChannelsForInputs()
386 { 350 {
387 for (unsigned i = 0; i < m_inputs.size(); ++i) 351 for (unsigned i = 0; i < m_inputs.size(); ++i)
388 input(i)->changedOutputs(); 352 input(i)->changedOutputs();
389 } 353 }
390 354
391 const AtomicString& AudioNode::interfaceName() const 355 const AtomicString& AudioNode::interfaceName() const
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 fprintf(stderr, "%d: %d\n", i, s_nodeCount[i]); 588 fprintf(stderr, "%d: %d\n", i, s_nodeCount[i]);
625 589
626 fprintf(stderr, "===========================\n\n\n"); 590 fprintf(stderr, "===========================\n\n\n");
627 } 591 }
628 592
629 #endif // DEBUG_AUDIONODE_REFERENCES 593 #endif // DEBUG_AUDIONODE_REFERENCES
630 594
631 } // namespace WebCore 595 } // namespace WebCore
632 596
633 #endif // ENABLE(WEB_AUDIO) 597 #endif // ENABLE(WEB_AUDIO)
OLDNEW
« no previous file with comments | « Source/modules/webaudio/AudioContext.cpp ('k') | Source/modules/webaudio/AudioScheduledSourceNode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698