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

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

Issue 24469004: Amusingly deprecate the generic version of 'ExceptionState::throwDOMException'. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 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/AudioBuffer.cpp ('k') | Source/modules/webaudio/AudioNode.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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 // of dealing with all of its ActiveDOMObjects at this point. uninitialize() can de-reference other 286 // of dealing with all of its ActiveDOMObjects at this point. uninitialize() can de-reference other
287 // ActiveDOMObjects so let's schedule uninitialize() to be called later. 287 // ActiveDOMObjects so let's schedule uninitialize() to be called later.
288 // FIXME: see if there's a more direct way to handle this issue. 288 // FIXME: see if there's a more direct way to handle this issue.
289 callOnMainThread(stopDispatch, this); 289 callOnMainThread(stopDispatch, this);
290 } 290 }
291 291
292 PassRefPtr<AudioBuffer> AudioContext::createBuffer(unsigned numberOfChannels, si ze_t numberOfFrames, float sampleRate, ExceptionState& es) 292 PassRefPtr<AudioBuffer> AudioContext::createBuffer(unsigned numberOfChannels, si ze_t numberOfFrames, float sampleRate, ExceptionState& es)
293 { 293 {
294 RefPtr<AudioBuffer> audioBuffer = AudioBuffer::create(numberOfChannels, numb erOfFrames, sampleRate); 294 RefPtr<AudioBuffer> audioBuffer = AudioBuffer::create(numberOfChannels, numb erOfFrames, sampleRate);
295 if (!audioBuffer.get()) { 295 if (!audioBuffer.get()) {
296 es.throwDOMException(SyntaxError); 296 es.throwUninformativeAndGenericDOMException(SyntaxError);
297 return 0; 297 return 0;
298 } 298 }
299 299
300 return audioBuffer; 300 return audioBuffer;
301 } 301 }
302 302
303 PassRefPtr<AudioBuffer> AudioContext::createBuffer(ArrayBuffer* arrayBuffer, boo l mixToMono, ExceptionState& es) 303 PassRefPtr<AudioBuffer> AudioContext::createBuffer(ArrayBuffer* arrayBuffer, boo l mixToMono, ExceptionState& es)
304 { 304 {
305 ASSERT(arrayBuffer); 305 ASSERT(arrayBuffer);
306 if (!arrayBuffer) { 306 if (!arrayBuffer) {
307 es.throwDOMException(SyntaxError); 307 es.throwUninformativeAndGenericDOMException(SyntaxError);
308 return 0; 308 return 0;
309 } 309 }
310 310
311 RefPtr<AudioBuffer> audioBuffer = AudioBuffer::createFromAudioFileData(array Buffer->data(), arrayBuffer->byteLength(), mixToMono, sampleRate()); 311 RefPtr<AudioBuffer> audioBuffer = AudioBuffer::createFromAudioFileData(array Buffer->data(), arrayBuffer->byteLength(), mixToMono, sampleRate());
312 if (!audioBuffer.get()) { 312 if (!audioBuffer.get()) {
313 es.throwDOMException(SyntaxError); 313 es.throwUninformativeAndGenericDOMException(SyntaxError);
314 return 0; 314 return 0;
315 } 315 }
316 316
317 return audioBuffer; 317 return audioBuffer;
318 } 318 }
319 319
320 void AudioContext::decodeAudioData(ArrayBuffer* audioData, PassRefPtr<AudioBuffe rCallback> successCallback, PassRefPtr<AudioBufferCallback> errorCallback, Excep tionState& es) 320 void AudioContext::decodeAudioData(ArrayBuffer* audioData, PassRefPtr<AudioBuffe rCallback> successCallback, PassRefPtr<AudioBufferCallback> errorCallback, Excep tionState& es)
321 { 321 {
322 if (!audioData) { 322 if (!audioData) {
323 es.throwDOMException(SyntaxError); 323 es.throwUninformativeAndGenericDOMException(SyntaxError);
324 return; 324 return;
325 } 325 }
326 m_audioDecoder.decodeAsync(audioData, sampleRate(), successCallback, errorCa llback); 326 m_audioDecoder.decodeAsync(audioData, sampleRate(), successCallback, errorCa llback);
327 } 327 }
328 328
329 PassRefPtr<AudioBufferSourceNode> AudioContext::createBufferSource() 329 PassRefPtr<AudioBufferSourceNode> AudioContext::createBufferSource()
330 { 330 {
331 ASSERT(isMainThread()); 331 ASSERT(isMainThread());
332 lazyInitialize(); 332 lazyInitialize();
333 RefPtr<AudioBufferSourceNode> node = AudioBufferSourceNode::create(this, m_d estinationNode->sampleRate()); 333 RefPtr<AudioBufferSourceNode> node = AudioBufferSourceNode::create(this, m_d estinationNode->sampleRate());
334 334
335 // Because this is an AudioScheduledSourceNode, the context keeps a referenc e until it has finished playing. 335 // Because this is an AudioScheduledSourceNode, the context keeps a referenc e until it has finished playing.
336 // When this happens, AudioScheduledSourceNode::finish() calls AudioContext: :notifyNodeFinishedProcessing(). 336 // When this happens, AudioScheduledSourceNode::finish() calls AudioContext: :notifyNodeFinishedProcessing().
337 refNode(node.get()); 337 refNode(node.get());
338 338
339 return node; 339 return node;
340 } 340 }
341 341
342 PassRefPtr<MediaElementAudioSourceNode> AudioContext::createMediaElementSource(H TMLMediaElement* mediaElement, ExceptionState& es) 342 PassRefPtr<MediaElementAudioSourceNode> AudioContext::createMediaElementSource(H TMLMediaElement* mediaElement, ExceptionState& es)
343 { 343 {
344 ASSERT(mediaElement); 344 ASSERT(mediaElement);
345 if (!mediaElement) { 345 if (!mediaElement) {
346 es.throwDOMException(InvalidStateError); 346 es.throwUninformativeAndGenericDOMException(InvalidStateError);
347 return 0; 347 return 0;
348 } 348 }
349 349
350 ASSERT(isMainThread()); 350 ASSERT(isMainThread());
351 lazyInitialize(); 351 lazyInitialize();
352 352
353 // First check if this media element already has a source node. 353 // First check if this media element already has a source node.
354 if (mediaElement->audioSourceNode()) { 354 if (mediaElement->audioSourceNode()) {
355 es.throwDOMException(InvalidStateError); 355 es.throwUninformativeAndGenericDOMException(InvalidStateError);
356 return 0; 356 return 0;
357 } 357 }
358 358
359 RefPtr<MediaElementAudioSourceNode> node = MediaElementAudioSourceNode::crea te(this, mediaElement); 359 RefPtr<MediaElementAudioSourceNode> node = MediaElementAudioSourceNode::crea te(this, mediaElement);
360 360
361 mediaElement->setAudioSourceNode(node.get()); 361 mediaElement->setAudioSourceNode(node.get());
362 362
363 refNode(node.get()); // context keeps reference until node is disconnected 363 refNode(node.get()); // context keeps reference until node is disconnected
364 return node; 364 return node;
365 } 365 }
366 366
367 PassRefPtr<MediaStreamAudioSourceNode> AudioContext::createMediaStreamSource(Med iaStream* mediaStream, ExceptionState& es) 367 PassRefPtr<MediaStreamAudioSourceNode> AudioContext::createMediaStreamSource(Med iaStream* mediaStream, ExceptionState& es)
368 { 368 {
369 ASSERT(mediaStream); 369 ASSERT(mediaStream);
370 if (!mediaStream) { 370 if (!mediaStream) {
371 es.throwDOMException(InvalidStateError); 371 es.throwUninformativeAndGenericDOMException(InvalidStateError);
372 return 0; 372 return 0;
373 } 373 }
374 374
375 ASSERT(isMainThread()); 375 ASSERT(isMainThread());
376 lazyInitialize(); 376 lazyInitialize();
377 377
378 AudioSourceProvider* provider = 0; 378 AudioSourceProvider* provider = 0;
379 379
380 MediaStreamTrackVector audioTracks = mediaStream->getAudioTracks(); 380 MediaStreamTrackVector audioTracks = mediaStream->getAudioTracks();
381 381
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 return createScriptProcessor(bufferSize, numberOfInputChannels, 2, es); 416 return createScriptProcessor(bufferSize, numberOfInputChannels, 2, es);
417 } 417 }
418 418
419 PassRefPtr<ScriptProcessorNode> AudioContext::createScriptProcessor(size_t buffe rSize, size_t numberOfInputChannels, size_t numberOfOutputChannels, ExceptionSta te& es) 419 PassRefPtr<ScriptProcessorNode> AudioContext::createScriptProcessor(size_t buffe rSize, size_t numberOfInputChannels, size_t numberOfOutputChannels, ExceptionSta te& es)
420 { 420 {
421 ASSERT(isMainThread()); 421 ASSERT(isMainThread());
422 lazyInitialize(); 422 lazyInitialize();
423 RefPtr<ScriptProcessorNode> node = ScriptProcessorNode::create(this, m_desti nationNode->sampleRate(), bufferSize, numberOfInputChannels, numberOfOutputChann els); 423 RefPtr<ScriptProcessorNode> node = ScriptProcessorNode::create(this, m_desti nationNode->sampleRate(), bufferSize, numberOfInputChannels, numberOfOutputChann els);
424 424
425 if (!node.get()) { 425 if (!node.get()) {
426 es.throwDOMException(SyntaxError); 426 es.throwUninformativeAndGenericDOMException(SyntaxError);
427 return 0; 427 return 0;
428 } 428 }
429 429
430 refNode(node.get()); // context keeps reference until we stop making javascr ipt rendering callbacks 430 refNode(node.get()); // context keeps reference until we stop making javascr ipt rendering callbacks
431 return node; 431 return node;
432 } 432 }
433 433
434 PassRefPtr<BiquadFilterNode> AudioContext::createBiquadFilter() 434 PassRefPtr<BiquadFilterNode> AudioContext::createBiquadFilter()
435 { 435 {
436 ASSERT(isMainThread()); 436 ASSERT(isMainThread());
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 } 503 }
504 504
505 PassRefPtr<ChannelSplitterNode> AudioContext::createChannelSplitter(size_t numbe rOfOutputs, ExceptionState& es) 505 PassRefPtr<ChannelSplitterNode> AudioContext::createChannelSplitter(size_t numbe rOfOutputs, ExceptionState& es)
506 { 506 {
507 ASSERT(isMainThread()); 507 ASSERT(isMainThread());
508 lazyInitialize(); 508 lazyInitialize();
509 509
510 RefPtr<ChannelSplitterNode> node = ChannelSplitterNode::create(this, m_desti nationNode->sampleRate(), numberOfOutputs); 510 RefPtr<ChannelSplitterNode> node = ChannelSplitterNode::create(this, m_desti nationNode->sampleRate(), numberOfOutputs);
511 511
512 if (!node.get()) { 512 if (!node.get()) {
513 es.throwDOMException(SyntaxError); 513 es.throwUninformativeAndGenericDOMException(SyntaxError);
514 return 0; 514 return 0;
515 } 515 }
516 516
517 return node; 517 return node;
518 } 518 }
519 519
520 PassRefPtr<ChannelMergerNode> AudioContext::createChannelMerger(ExceptionState& es) 520 PassRefPtr<ChannelMergerNode> AudioContext::createChannelMerger(ExceptionState& es)
521 { 521 {
522 const unsigned ChannelMergerDefaultNumberOfInputs = 6; 522 const unsigned ChannelMergerDefaultNumberOfInputs = 6;
523 return createChannelMerger(ChannelMergerDefaultNumberOfInputs, es); 523 return createChannelMerger(ChannelMergerDefaultNumberOfInputs, es);
524 } 524 }
525 525
526 PassRefPtr<ChannelMergerNode> AudioContext::createChannelMerger(size_t numberOfI nputs, ExceptionState& es) 526 PassRefPtr<ChannelMergerNode> AudioContext::createChannelMerger(size_t numberOfI nputs, ExceptionState& es)
527 { 527 {
528 ASSERT(isMainThread()); 528 ASSERT(isMainThread());
529 lazyInitialize(); 529 lazyInitialize();
530 530
531 RefPtr<ChannelMergerNode> node = ChannelMergerNode::create(this, m_destinati onNode->sampleRate(), numberOfInputs); 531 RefPtr<ChannelMergerNode> node = ChannelMergerNode::create(this, m_destinati onNode->sampleRate(), numberOfInputs);
532 532
533 if (!node.get()) { 533 if (!node.get()) {
534 es.throwDOMException(SyntaxError); 534 es.throwUninformativeAndGenericDOMException(SyntaxError);
535 return 0; 535 return 0;
536 } 536 }
537 537
538 return node; 538 return node;
539 } 539 }
540 540
541 PassRefPtr<OscillatorNode> AudioContext::createOscillator() 541 PassRefPtr<OscillatorNode> AudioContext::createOscillator()
542 { 542 {
543 ASSERT(isMainThread()); 543 ASSERT(isMainThread());
544 lazyInitialize(); 544 lazyInitialize();
545 545
546 RefPtr<OscillatorNode> node = OscillatorNode::create(this, m_destinationNode ->sampleRate()); 546 RefPtr<OscillatorNode> node = OscillatorNode::create(this, m_destinationNode ->sampleRate());
547 547
548 // Because this is an AudioScheduledSourceNode, the context keeps a referenc e until it has finished playing. 548 // Because this is an AudioScheduledSourceNode, the context keeps a referenc e until it has finished playing.
549 // When this happens, AudioScheduledSourceNode::finish() calls AudioContext: :notifyNodeFinishedProcessing(). 549 // When this happens, AudioScheduledSourceNode::finish() calls AudioContext: :notifyNodeFinishedProcessing().
550 refNode(node.get()); 550 refNode(node.get());
551 551
552 return node; 552 return node;
553 } 553 }
554 554
555 PassRefPtr<PeriodicWave> AudioContext::createPeriodicWave(Float32Array* real, Fl oat32Array* imag, ExceptionState& es) 555 PassRefPtr<PeriodicWave> AudioContext::createPeriodicWave(Float32Array* real, Fl oat32Array* imag, ExceptionState& es)
556 { 556 {
557 ASSERT(isMainThread()); 557 ASSERT(isMainThread());
558 558
559 if (!real || !imag || (real->length() != imag->length())) { 559 if (!real || !imag || (real->length() != imag->length())) {
560 es.throwDOMException(SyntaxError); 560 es.throwUninformativeAndGenericDOMException(SyntaxError);
561 return 0; 561 return 0;
562 } 562 }
563 563
564 lazyInitialize(); 564 lazyInitialize();
565 return PeriodicWave::create(sampleRate(), real, imag); 565 return PeriodicWave::create(sampleRate(), real, imag);
566 } 566 }
567 567
568 void AudioContext::notifyNodeFinishedProcessing(AudioNode* node) 568 void AudioContext::notifyNodeFinishedProcessing(AudioNode* node)
569 { 569 {
570 ASSERT(isAudioThread()); 570 ASSERT(isAudioThread());
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 } 951 }
952 952
953 void AudioContext::decrementActiveSourceCount() 953 void AudioContext::decrementActiveSourceCount()
954 { 954 {
955 atomicDecrement(&m_activeSourceCount); 955 atomicDecrement(&m_activeSourceCount);
956 } 956 }
957 957
958 } // namespace WebCore 958 } // namespace WebCore
959 959
960 #endif // ENABLE(WEB_AUDIO) 960 #endif // ENABLE(WEB_AUDIO)
OLDNEW
« no previous file with comments | « Source/modules/webaudio/AudioBuffer.cpp ('k') | Source/modules/webaudio/AudioNode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698