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

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

Issue 72363002: Rename es => exceptionState in other than bindings/ (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Retry Created 7 years, 1 month 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
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 { 82 {
83 // FIXME: It would be nice if the minimum sample-rate could be less than 44. 1KHz, 83 // FIXME: It would be nice if the minimum sample-rate could be less than 44. 1KHz,
84 // but that will require some fixes in HRTFPanner::fftSizeForSampleRate(), a nd some testing there. 84 // but that will require some fixes in HRTFPanner::fftSizeForSampleRate(), a nd some testing there.
85 return sampleRate >= 44100 && sampleRate <= 96000; 85 return sampleRate >= 44100 && sampleRate <= 96000;
86 } 86 }
87 87
88 // Don't allow more than this number of simultaneous AudioContexts talking to ha rdware. 88 // Don't allow more than this number of simultaneous AudioContexts talking to ha rdware.
89 const unsigned MaxHardwareContexts = 4; 89 const unsigned MaxHardwareContexts = 4;
90 unsigned AudioContext::s_hardwareContextCount = 0; 90 unsigned AudioContext::s_hardwareContextCount = 0;
91 91
92 PassRefPtr<AudioContext> AudioContext::create(Document& document, ExceptionState & es) 92 PassRefPtr<AudioContext> AudioContext::create(Document& document, ExceptionState & exceptionState)
93 { 93 {
94 ASSERT(isMainThread()); 94 ASSERT(isMainThread());
95 if (s_hardwareContextCount >= MaxHardwareContexts) { 95 if (s_hardwareContextCount >= MaxHardwareContexts) {
96 es.throwDOMException( 96 exceptionState.throwDOMException(
97 SyntaxError, 97 SyntaxError,
98 ExceptionMessages::failedToConstruct( 98 ExceptionMessages::failedToConstruct(
99 "AudioContext", 99 "AudioContext",
100 "number of hardware contexts reached maximum (" + String::number (MaxHardwareContexts) + ").")); 100 "number of hardware contexts reached maximum (" + String::number (MaxHardwareContexts) + ")."));
101 return 0; 101 return 0;
102 } 102 }
103 103
104 RefPtr<AudioContext> audioContext(adoptRef(new AudioContext(&document))); 104 RefPtr<AudioContext> audioContext(adoptRef(new AudioContext(&document)));
105 audioContext->suspendIfNeeded(); 105 audioContext->suspendIfNeeded();
106 return audioContext.release(); 106 return audioContext.release();
107 } 107 }
108 108
109 PassRefPtr<AudioContext> AudioContext::create(Document& document, unsigned numbe rOfChannels, size_t numberOfFrames, float sampleRate, ExceptionState& es) 109 PassRefPtr<AudioContext> AudioContext::create(Document& document, unsigned numbe rOfChannels, size_t numberOfFrames, float sampleRate, ExceptionState& exceptionS tate)
110 { 110 {
111 document.addConsoleMessage(JSMessageSource, WarningMessageLevel, "Deprecated AudioContext constructor: use OfflineAudioContext instead"); 111 document.addConsoleMessage(JSMessageSource, WarningMessageLevel, "Deprecated AudioContext constructor: use OfflineAudioContext instead");
112 return OfflineAudioContext::create(&document, numberOfChannels, numberOfFram es, sampleRate, es); 112 return OfflineAudioContext::create(&document, numberOfChannels, numberOfFram es, sampleRate, exceptionState);
113 } 113 }
114 114
115 // Constructor for rendering to the audio hardware. 115 // Constructor for rendering to the audio hardware.
116 AudioContext::AudioContext(Document* document) 116 AudioContext::AudioContext(Document* document)
117 : ActiveDOMObject(document) 117 : ActiveDOMObject(document)
118 , m_isStopScheduled(false) 118 , m_isStopScheduled(false)
119 , m_isInitialized(false) 119 , m_isInitialized(false)
120 , m_isAudioThreadFinished(false) 120 , m_isAudioThreadFinished(false)
121 , m_destinationNode(0) 121 , m_destinationNode(0)
122 , m_isDeletionScheduled(false) 122 , m_isDeletionScheduled(false)
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 return; 289 return;
290 m_isStopScheduled = true; 290 m_isStopScheduled = true;
291 291
292 // Don't call uninitialize() immediately here because the ExecutionContext i s in the middle 292 // Don't call uninitialize() immediately here because the ExecutionContext i s in the middle
293 // of dealing with all of its ActiveDOMObjects at this point. uninitialize() can de-reference other 293 // of dealing with all of its ActiveDOMObjects at this point. uninitialize() can de-reference other
294 // ActiveDOMObjects so let's schedule uninitialize() to be called later. 294 // ActiveDOMObjects so let's schedule uninitialize() to be called later.
295 // FIXME: see if there's a more direct way to handle this issue. 295 // FIXME: see if there's a more direct way to handle this issue.
296 callOnMainThread(stopDispatch, this); 296 callOnMainThread(stopDispatch, this);
297 } 297 }
298 298
299 PassRefPtr<AudioBuffer> AudioContext::createBuffer(unsigned numberOfChannels, si ze_t numberOfFrames, float sampleRate, ExceptionState& es) 299 PassRefPtr<AudioBuffer> AudioContext::createBuffer(unsigned numberOfChannels, si ze_t numberOfFrames, float sampleRate, ExceptionState& exceptionState)
300 { 300 {
301 RefPtr<AudioBuffer> audioBuffer = AudioBuffer::create(numberOfChannels, numb erOfFrames, sampleRate); 301 RefPtr<AudioBuffer> audioBuffer = AudioBuffer::create(numberOfChannels, numb erOfFrames, sampleRate);
302 if (!audioBuffer.get()) { 302 if (!audioBuffer.get()) {
303 if (numberOfChannels > AudioContext::maxNumberOfChannels()) { 303 if (numberOfChannels > AudioContext::maxNumberOfChannels()) {
304 es.throwDOMException( 304 exceptionState.throwDOMException(
305 NotSupportedError, 305 NotSupportedError,
306 ExceptionMessages::failedToConstruct( 306 ExceptionMessages::failedToConstruct(
307 "AudioBuffer", 307 "AudioBuffer",
308 "requested number of channels (" + String::number(numberOfCh annels) + ") exceeds maximum (" + String::number(AudioContext::maxNumberOfChanne ls()) + ")")); 308 "requested number of channels (" + String::number(numberOfCh annels) + ") exceeds maximum (" + String::number(AudioContext::maxNumberOfChanne ls()) + ")"));
309 } else if (sampleRate < AudioBuffer::minAllowedSampleRate() || sampleRat e > AudioBuffer::maxAllowedSampleRate()) { 309 } else if (sampleRate < AudioBuffer::minAllowedSampleRate() || sampleRat e > AudioBuffer::maxAllowedSampleRate()) {
310 es.throwDOMException( 310 exceptionState.throwDOMException(
311 NotSupportedError, 311 NotSupportedError,
312 ExceptionMessages::failedToConstruct( 312 ExceptionMessages::failedToConstruct(
313 "AudioBuffer", 313 "AudioBuffer",
314 "requested sample rate (" + String::number(sampleRate) 314 "requested sample rate (" + String::number(sampleRate)
315 + ") does not lie in the allowed range of " 315 + ") does not lie in the allowed range of "
316 + String::number(AudioBuffer::minAllowedSampleRate()) 316 + String::number(AudioBuffer::minAllowedSampleRate())
317 + "-" + String::number(AudioBuffer::maxAllowedSampleRate()) + " Hz")); 317 + "-" + String::number(AudioBuffer::maxAllowedSampleRate()) + " Hz"));
318 } else if (!numberOfFrames) { 318 } else if (!numberOfFrames) {
319 es.throwDOMException( 319 exceptionState.throwDOMException(
320 NotSupportedError, 320 NotSupportedError,
321 ExceptionMessages::failedToConstruct( 321 ExceptionMessages::failedToConstruct(
322 "AudioBuffer", 322 "AudioBuffer",
323 "number of frames must be greater than 0.")); 323 "number of frames must be greater than 0."));
324 } else { 324 } else {
325 es.throwDOMException( 325 exceptionState.throwDOMException(
326 NotSupportedError, 326 NotSupportedError,
327 ExceptionMessages::failedToConstruct( 327 ExceptionMessages::failedToConstruct(
328 "AudioBuffer", 328 "AudioBuffer",
329 "unable to create buffer of " + String::number(numberOfChann els) 329 "unable to create buffer of " + String::number(numberOfChann els)
330 + " channel(s) of " + String::number(numberOfFrames) 330 + " channel(s) of " + String::number(numberOfFrames)
331 + " frames each.")); 331 + " frames each."));
332 } 332 }
333 return 0; 333 return 0;
334 } 334 }
335 335
336 return audioBuffer; 336 return audioBuffer;
337 } 337 }
338 338
339 PassRefPtr<AudioBuffer> AudioContext::createBuffer(ArrayBuffer* arrayBuffer, boo l mixToMono, ExceptionState& es) 339 PassRefPtr<AudioBuffer> AudioContext::createBuffer(ArrayBuffer* arrayBuffer, boo l mixToMono, ExceptionState& exceptionState)
340 { 340 {
341 ASSERT(arrayBuffer); 341 ASSERT(arrayBuffer);
342 if (!arrayBuffer) { 342 if (!arrayBuffer) {
343 es.throwDOMException( 343 exceptionState.throwDOMException(
344 SyntaxError, 344 SyntaxError,
345 ExceptionMessages::failedToConstruct( 345 ExceptionMessages::failedToConstruct(
346 "AudioBuffer", 346 "AudioBuffer",
347 "invalid ArrayBuffer.")); 347 "invalid ArrayBuffer."));
348 return 0; 348 return 0;
349 } 349 }
350 350
351 RefPtr<AudioBuffer> audioBuffer = AudioBuffer::createFromAudioFileData(array Buffer->data(), arrayBuffer->byteLength(), mixToMono, sampleRate()); 351 RefPtr<AudioBuffer> audioBuffer = AudioBuffer::createFromAudioFileData(array Buffer->data(), arrayBuffer->byteLength(), mixToMono, sampleRate());
352 if (!audioBuffer.get()) { 352 if (!audioBuffer.get()) {
353 es.throwDOMException( 353 exceptionState.throwDOMException(
354 SyntaxError, 354 SyntaxError,
355 ExceptionMessages::failedToConstruct( 355 ExceptionMessages::failedToConstruct(
356 "AudioBuffer", 356 "AudioBuffer",
357 "invalid audio data in ArrayBuffer.")); 357 "invalid audio data in ArrayBuffer."));
358 return 0; 358 return 0;
359 } 359 }
360 360
361 return audioBuffer; 361 return audioBuffer;
362 } 362 }
363 363
364 void AudioContext::decodeAudioData(ArrayBuffer* audioData, PassRefPtr<AudioBuffe rCallback> successCallback, PassRefPtr<AudioBufferCallback> errorCallback, Excep tionState& es) 364 void AudioContext::decodeAudioData(ArrayBuffer* audioData, PassRefPtr<AudioBuffe rCallback> successCallback, PassRefPtr<AudioBufferCallback> errorCallback, Excep tionState& exceptionState)
365 { 365 {
366 if (!audioData) { 366 if (!audioData) {
367 es.throwDOMException( 367 exceptionState.throwDOMException(
368 SyntaxError, 368 SyntaxError,
369 ExceptionMessages::failedToExecute( 369 ExceptionMessages::failedToExecute(
370 "decodeAudioData", 370 "decodeAudioData",
371 "AudioContext", 371 "AudioContext",
372 "invalid ArrayBuffer for audioData.")); 372 "invalid ArrayBuffer for audioData."));
373 return; 373 return;
374 } 374 }
375 m_audioDecoder.decodeAsync(audioData, sampleRate(), successCallback, errorCa llback); 375 m_audioDecoder.decodeAsync(audioData, sampleRate(), successCallback, errorCa llback);
376 } 376 }
377 377
378 PassRefPtr<AudioBufferSourceNode> AudioContext::createBufferSource() 378 PassRefPtr<AudioBufferSourceNode> AudioContext::createBufferSource()
379 { 379 {
380 ASSERT(isMainThread()); 380 ASSERT(isMainThread());
381 lazyInitialize(); 381 lazyInitialize();
382 RefPtr<AudioBufferSourceNode> node = AudioBufferSourceNode::create(this, m_d estinationNode->sampleRate()); 382 RefPtr<AudioBufferSourceNode> node = AudioBufferSourceNode::create(this, m_d estinationNode->sampleRate());
383 383
384 // Because this is an AudioScheduledSourceNode, the context keeps a referenc e until it has finished playing. 384 // Because this is an AudioScheduledSourceNode, the context keeps a referenc e until it has finished playing.
385 // When this happens, AudioScheduledSourceNode::finish() calls AudioContext: :notifyNodeFinishedProcessing(). 385 // When this happens, AudioScheduledSourceNode::finish() calls AudioContext: :notifyNodeFinishedProcessing().
386 refNode(node.get()); 386 refNode(node.get());
387 387
388 return node; 388 return node;
389 } 389 }
390 390
391 PassRefPtr<MediaElementAudioSourceNode> AudioContext::createMediaElementSource(H TMLMediaElement* mediaElement, ExceptionState& es) 391 PassRefPtr<MediaElementAudioSourceNode> AudioContext::createMediaElementSource(H TMLMediaElement* mediaElement, ExceptionState& exceptionState)
392 { 392 {
393 if (!mediaElement) { 393 if (!mediaElement) {
394 es.throwDOMException( 394 exceptionState.throwDOMException(
395 InvalidStateError, 395 InvalidStateError,
396 ExceptionMessages::failedToConstruct( 396 ExceptionMessages::failedToConstruct(
397 "MediaElementAudioSourceNode", 397 "MediaElementAudioSourceNode",
398 "invalid HTMLMedialElement.")); 398 "invalid HTMLMedialElement."));
399 return 0; 399 return 0;
400 } 400 }
401 401
402 ASSERT(isMainThread()); 402 ASSERT(isMainThread());
403 lazyInitialize(); 403 lazyInitialize();
404 404
405 // First check if this media element already has a source node. 405 // First check if this media element already has a source node.
406 if (mediaElement->audioSourceNode()) { 406 if (mediaElement->audioSourceNode()) {
407 es.throwDOMException( 407 exceptionState.throwDOMException(
408 InvalidStateError, 408 InvalidStateError,
409 ExceptionMessages::failedToConstruct( 409 ExceptionMessages::failedToConstruct(
410 "MediaElementAudioSourceNode", 410 "MediaElementAudioSourceNode",
411 "invalid HTMLMediaElement.")); 411 "invalid HTMLMediaElement."));
412 return 0; 412 return 0;
413 } 413 }
414 414
415 RefPtr<MediaElementAudioSourceNode> node = MediaElementAudioSourceNode::crea te(this, mediaElement); 415 RefPtr<MediaElementAudioSourceNode> node = MediaElementAudioSourceNode::crea te(this, mediaElement);
416 416
417 mediaElement->setAudioSourceNode(node.get()); 417 mediaElement->setAudioSourceNode(node.get());
418 418
419 refNode(node.get()); // context keeps reference until node is disconnected 419 refNode(node.get()); // context keeps reference until node is disconnected
420 return node; 420 return node;
421 } 421 }
422 422
423 PassRefPtr<MediaStreamAudioSourceNode> AudioContext::createMediaStreamSource(Med iaStream* mediaStream, ExceptionState& es) 423 PassRefPtr<MediaStreamAudioSourceNode> AudioContext::createMediaStreamSource(Med iaStream* mediaStream, ExceptionState& exceptionState)
424 { 424 {
425 if (!mediaStream) { 425 if (!mediaStream) {
426 es.throwDOMException( 426 exceptionState.throwDOMException(
427 InvalidStateError, 427 InvalidStateError,
428 ExceptionMessages::failedToConstruct( 428 ExceptionMessages::failedToConstruct(
429 "MediaStreamAudioSourceNode", 429 "MediaStreamAudioSourceNode",
430 "invalid MediaStream source")); 430 "invalid MediaStream source"));
431 return 0; 431 return 0;
432 } 432 }
433 433
434 ASSERT(isMainThread()); 434 ASSERT(isMainThread());
435 lazyInitialize(); 435 lazyInitialize();
436 436
(...skipping 19 matching lines...) Expand all
456 return node; 456 return node;
457 } 457 }
458 458
459 PassRefPtr<MediaStreamAudioDestinationNode> AudioContext::createMediaStreamDesti nation() 459 PassRefPtr<MediaStreamAudioDestinationNode> AudioContext::createMediaStreamDesti nation()
460 { 460 {
461 // FIXME: Add support for an optional argument which specifies the number of channels. 461 // FIXME: Add support for an optional argument which specifies the number of channels.
462 // FIXME: The default should probably be stereo instead of mono. 462 // FIXME: The default should probably be stereo instead of mono.
463 return MediaStreamAudioDestinationNode::create(this, 1); 463 return MediaStreamAudioDestinationNode::create(this, 1);
464 } 464 }
465 465
466 PassRefPtr<ScriptProcessorNode> AudioContext::createScriptProcessor(ExceptionSta te& es) 466 PassRefPtr<ScriptProcessorNode> AudioContext::createScriptProcessor(ExceptionSta te& exceptionState)
467 { 467 {
468 // Set number of input/output channels to stereo by default. 468 // Set number of input/output channels to stereo by default.
469 return createScriptProcessor(0, 2, 2, es); 469 return createScriptProcessor(0, 2, 2, exceptionState);
470 } 470 }
471 471
472 PassRefPtr<ScriptProcessorNode> AudioContext::createScriptProcessor(size_t buffe rSize, ExceptionState& es) 472 PassRefPtr<ScriptProcessorNode> AudioContext::createScriptProcessor(size_t buffe rSize, ExceptionState& exceptionState)
473 { 473 {
474 // Set number of input/output channels to stereo by default. 474 // Set number of input/output channels to stereo by default.
475 return createScriptProcessor(bufferSize, 2, 2, es); 475 return createScriptProcessor(bufferSize, 2, 2, exceptionState);
476 } 476 }
477 477
478 PassRefPtr<ScriptProcessorNode> AudioContext::createScriptProcessor(size_t buffe rSize, size_t numberOfInputChannels, ExceptionState& es) 478 PassRefPtr<ScriptProcessorNode> AudioContext::createScriptProcessor(size_t buffe rSize, size_t numberOfInputChannels, ExceptionState& exceptionState)
479 { 479 {
480 // Set number of output channels to stereo by default. 480 // Set number of output channels to stereo by default.
481 return createScriptProcessor(bufferSize, numberOfInputChannels, 2, es); 481 return createScriptProcessor(bufferSize, numberOfInputChannels, 2, exception State);
482 } 482 }
483 483
484 PassRefPtr<ScriptProcessorNode> AudioContext::createScriptProcessor(size_t buffe rSize, size_t numberOfInputChannels, size_t numberOfOutputChannels, ExceptionSta te& es) 484 PassRefPtr<ScriptProcessorNode> AudioContext::createScriptProcessor(size_t buffe rSize, size_t numberOfInputChannels, size_t numberOfOutputChannels, ExceptionSta te& exceptionState)
485 { 485 {
486 ASSERT(isMainThread()); 486 ASSERT(isMainThread());
487 lazyInitialize(); 487 lazyInitialize();
488 RefPtr<ScriptProcessorNode> node = ScriptProcessorNode::create(this, m_desti nationNode->sampleRate(), bufferSize, numberOfInputChannels, numberOfOutputChann els); 488 RefPtr<ScriptProcessorNode> node = ScriptProcessorNode::create(this, m_desti nationNode->sampleRate(), bufferSize, numberOfInputChannels, numberOfOutputChann els);
489 489
490 if (!node.get()) { 490 if (!node.get()) {
491 if (!numberOfInputChannels && !numberOfOutputChannels) { 491 if (!numberOfInputChannels && !numberOfOutputChannels) {
492 es.throwDOMException( 492 exceptionState.throwDOMException(
493 IndexSizeError, 493 IndexSizeError,
494 ExceptionMessages::failedToConstruct( 494 ExceptionMessages::failedToConstruct(
495 "ScriptProcessorNode", 495 "ScriptProcessorNode",
496 "number of input channels and output channels cannot both be zero.")); 496 "number of input channels and output channels cannot both be zero."));
497 } else if (numberOfInputChannels > AudioContext::maxNumberOfChannels()) { 497 } else if (numberOfInputChannels > AudioContext::maxNumberOfChannels()) {
498 es.throwDOMException( 498 exceptionState.throwDOMException(
499 IndexSizeError, 499 IndexSizeError,
500 ExceptionMessages::failedToConstruct( 500 ExceptionMessages::failedToConstruct(
501 "ScriptProcessorNode", 501 "ScriptProcessorNode",
502 "number of input channels (" + String::number(numberOfInputC hannels) 502 "number of input channels (" + String::number(numberOfInputC hannels)
503 + ") exceeds maximum (" 503 + ") exceeds maximum ("
504 + String::number(AudioContext::maxNumberOfChannels()) + ")." )); 504 + String::number(AudioContext::maxNumberOfChannels()) + ")." ));
505 } else if (numberOfOutputChannels > AudioContext::maxNumberOfChannels()) { 505 } else if (numberOfOutputChannels > AudioContext::maxNumberOfChannels()) {
506 es.throwDOMException( 506 exceptionState.throwDOMException(
507 IndexSizeError, 507 IndexSizeError,
508 ExceptionMessages::failedToConstruct( 508 ExceptionMessages::failedToConstruct(
509 "ScriptProcessorNode", 509 "ScriptProcessorNode",
510 "number of output channels (" + String::number(numberOfInput Channels) 510 "number of output channels (" + String::number(numberOfInput Channels)
511 + ") exceeds maximum (" 511 + ") exceeds maximum ("
512 + String::number(AudioContext::maxNumberOfChannels()) + ")." )); 512 + String::number(AudioContext::maxNumberOfChannels()) + ")." ));
513 } else { 513 } else {
514 es.throwDOMException( 514 exceptionState.throwDOMException(
515 IndexSizeError, 515 IndexSizeError,
516 ExceptionMessages::failedToConstruct( 516 ExceptionMessages::failedToConstruct(
517 "ScriptProcessorNode", 517 "ScriptProcessorNode",
518 "buffer size (" + String::number(bufferSize) 518 "buffer size (" + String::number(bufferSize)
519 + ") must be a power of two between 256 and 16384.")); 519 + ") must be a power of two between 256 and 16384."));
520 } 520 }
521 return 0; 521 return 0;
522 } 522 }
523 523
524 refNode(node.get()); // context keeps reference until we stop making javascr ipt rendering callbacks 524 refNode(node.get()); // context keeps reference until we stop making javascr ipt rendering callbacks
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 return AnalyserNode::create(this, m_destinationNode->sampleRate()); 567 return AnalyserNode::create(this, m_destinationNode->sampleRate());
568 } 568 }
569 569
570 PassRefPtr<GainNode> AudioContext::createGain() 570 PassRefPtr<GainNode> AudioContext::createGain()
571 { 571 {
572 ASSERT(isMainThread()); 572 ASSERT(isMainThread());
573 lazyInitialize(); 573 lazyInitialize();
574 return GainNode::create(this, m_destinationNode->sampleRate()); 574 return GainNode::create(this, m_destinationNode->sampleRate());
575 } 575 }
576 576
577 PassRefPtr<DelayNode> AudioContext::createDelay(ExceptionState& es) 577 PassRefPtr<DelayNode> AudioContext::createDelay(ExceptionState& exceptionState)
578 { 578 {
579 const double defaultMaxDelayTime = 1; 579 const double defaultMaxDelayTime = 1;
580 return createDelay(defaultMaxDelayTime, es); 580 return createDelay(defaultMaxDelayTime, exceptionState);
581 } 581 }
582 582
583 PassRefPtr<DelayNode> AudioContext::createDelay(double maxDelayTime, ExceptionSt ate& es) 583 PassRefPtr<DelayNode> AudioContext::createDelay(double maxDelayTime, ExceptionSt ate& exceptionState)
584 { 584 {
585 ASSERT(isMainThread()); 585 ASSERT(isMainThread());
586 lazyInitialize(); 586 lazyInitialize();
587 RefPtr<DelayNode> node = DelayNode::create(this, m_destinationNode->sampleRa te(), maxDelayTime, es); 587 RefPtr<DelayNode> node = DelayNode::create(this, m_destinationNode->sampleRa te(), maxDelayTime, exceptionState);
588 if (es.hadException()) 588 if (exceptionState.hadException())
589 return 0; 589 return 0;
590 return node; 590 return node;
591 } 591 }
592 592
593 PassRefPtr<ChannelSplitterNode> AudioContext::createChannelSplitter(ExceptionSta te& es) 593 PassRefPtr<ChannelSplitterNode> AudioContext::createChannelSplitter(ExceptionSta te& exceptionState)
594 { 594 {
595 const unsigned ChannelSplitterDefaultNumberOfOutputs = 6; 595 const unsigned ChannelSplitterDefaultNumberOfOutputs = 6;
596 return createChannelSplitter(ChannelSplitterDefaultNumberOfOutputs, es); 596 return createChannelSplitter(ChannelSplitterDefaultNumberOfOutputs, exceptio nState);
597 } 597 }
598 598
599 PassRefPtr<ChannelSplitterNode> AudioContext::createChannelSplitter(size_t numbe rOfOutputs, ExceptionState& es) 599 PassRefPtr<ChannelSplitterNode> AudioContext::createChannelSplitter(size_t numbe rOfOutputs, ExceptionState& exceptionState)
600 { 600 {
601 ASSERT(isMainThread()); 601 ASSERT(isMainThread());
602 lazyInitialize(); 602 lazyInitialize();
603 603
604 RefPtr<ChannelSplitterNode> node = ChannelSplitterNode::create(this, m_desti nationNode->sampleRate(), numberOfOutputs); 604 RefPtr<ChannelSplitterNode> node = ChannelSplitterNode::create(this, m_desti nationNode->sampleRate(), numberOfOutputs);
605 605
606 if (!node.get()) { 606 if (!node.get()) {
607 es.throwDOMException( 607 exceptionState.throwDOMException(
608 IndexSizeError, 608 IndexSizeError,
609 ExceptionMessages::failedToConstruct( 609 ExceptionMessages::failedToConstruct(
610 "ChannelSplitterNode", 610 "ChannelSplitterNode",
611 "number of outputs (" + String::number(numberOfOutputs) 611 "number of outputs (" + String::number(numberOfOutputs)
612 + ") must be between 1 and " 612 + ") must be between 1 and "
613 + String::number(AudioContext::maxNumberOfChannels()) + ".")); 613 + String::number(AudioContext::maxNumberOfChannels()) + "."));
614 return 0; 614 return 0;
615 } 615 }
616 616
617 return node; 617 return node;
618 } 618 }
619 619
620 PassRefPtr<ChannelMergerNode> AudioContext::createChannelMerger(ExceptionState& es) 620 PassRefPtr<ChannelMergerNode> AudioContext::createChannelMerger(ExceptionState& exceptionState)
621 { 621 {
622 const unsigned ChannelMergerDefaultNumberOfInputs = 6; 622 const unsigned ChannelMergerDefaultNumberOfInputs = 6;
623 return createChannelMerger(ChannelMergerDefaultNumberOfInputs, es); 623 return createChannelMerger(ChannelMergerDefaultNumberOfInputs, exceptionStat e);
624 } 624 }
625 625
626 PassRefPtr<ChannelMergerNode> AudioContext::createChannelMerger(size_t numberOfI nputs, ExceptionState& es) 626 PassRefPtr<ChannelMergerNode> AudioContext::createChannelMerger(size_t numberOfI nputs, ExceptionState& exceptionState)
627 { 627 {
628 ASSERT(isMainThread()); 628 ASSERT(isMainThread());
629 lazyInitialize(); 629 lazyInitialize();
630 630
631 RefPtr<ChannelMergerNode> node = ChannelMergerNode::create(this, m_destinati onNode->sampleRate(), numberOfInputs); 631 RefPtr<ChannelMergerNode> node = ChannelMergerNode::create(this, m_destinati onNode->sampleRate(), numberOfInputs);
632 632
633 if (!node.get()) { 633 if (!node.get()) {
634 es.throwDOMException( 634 exceptionState.throwDOMException(
635 IndexSizeError, 635 IndexSizeError,
636 ExceptionMessages::failedToConstruct( 636 ExceptionMessages::failedToConstruct(
637 "ChannelMergerNode", 637 "ChannelMergerNode",
638 "number of inputs (" + String::number(numberOfInputs) 638 "number of inputs (" + String::number(numberOfInputs)
639 + ") must be between 1 and " 639 + ") must be between 1 and "
640 + String::number(AudioContext::maxNumberOfChannels()) + ".")); 640 + String::number(AudioContext::maxNumberOfChannels()) + "."));
641 return 0; 641 return 0;
642 } 642 }
643 643
644 return node; 644 return node;
645 } 645 }
646 646
647 PassRefPtr<OscillatorNode> AudioContext::createOscillator() 647 PassRefPtr<OscillatorNode> AudioContext::createOscillator()
648 { 648 {
649 ASSERT(isMainThread()); 649 ASSERT(isMainThread());
650 lazyInitialize(); 650 lazyInitialize();
651 651
652 RefPtr<OscillatorNode> node = OscillatorNode::create(this, m_destinationNode ->sampleRate()); 652 RefPtr<OscillatorNode> node = OscillatorNode::create(this, m_destinationNode ->sampleRate());
653 653
654 // Because this is an AudioScheduledSourceNode, the context keeps a referenc e until it has finished playing. 654 // Because this is an AudioScheduledSourceNode, the context keeps a referenc e until it has finished playing.
655 // When this happens, AudioScheduledSourceNode::finish() calls AudioContext: :notifyNodeFinishedProcessing(). 655 // When this happens, AudioScheduledSourceNode::finish() calls AudioContext: :notifyNodeFinishedProcessing().
656 refNode(node.get()); 656 refNode(node.get());
657 657
658 return node; 658 return node;
659 } 659 }
660 660
661 PassRefPtr<PeriodicWave> AudioContext::createPeriodicWave(Float32Array* real, Fl oat32Array* imag, ExceptionState& es) 661 PassRefPtr<PeriodicWave> AudioContext::createPeriodicWave(Float32Array* real, Fl oat32Array* imag, ExceptionState& exceptionState)
662 { 662 {
663 ASSERT(isMainThread()); 663 ASSERT(isMainThread());
664 664
665 if (!real) { 665 if (!real) {
666 es.throwDOMException( 666 exceptionState.throwDOMException(
667 SyntaxError, 667 SyntaxError,
668 ExceptionMessages::failedToConstruct( 668 ExceptionMessages::failedToConstruct(
669 "PeriodicWave", 669 "PeriodicWave",
670 "invalid real array")); 670 "invalid real array"));
671 return 0; 671 return 0;
672 } 672 }
673 673
674 if (!imag) { 674 if (!imag) {
675 es.throwDOMException( 675 exceptionState.throwDOMException(
676 SyntaxError, 676 SyntaxError,
677 ExceptionMessages::failedToConstruct( 677 ExceptionMessages::failedToConstruct(
678 "PeriodicWave", 678 "PeriodicWave",
679 "invalid imaginary array")); 679 "invalid imaginary array"));
680 return 0; 680 return 0;
681 } 681 }
682 682
683 if (real->length() != imag->length()) { 683 if (real->length() != imag->length()) {
684 es.throwDOMException( 684 exceptionState.throwDOMException(
685 IndexSizeError, 685 IndexSizeError,
686 ExceptionMessages::failedToConstruct( 686 ExceptionMessages::failedToConstruct(
687 "PeriodicWave", 687 "PeriodicWave",
688 "length of real array (" + String::number(real->length()) 688 "length of real array (" + String::number(real->length())
689 + ") and length of imaginary array (" + String::number(imag->le ngth()) 689 + ") and length of imaginary array (" + String::number(imag->le ngth())
690 + ") must match.")); 690 + ") must match."));
691 return 0; 691 return 0;
692 } 692 }
693 693
694 if (real->length() > 4096) { 694 if (real->length() > 4096) {
695 es.throwDOMException( 695 exceptionState.throwDOMException(
696 IndexSizeError, 696 IndexSizeError,
697 ExceptionMessages::failedToConstruct( 697 ExceptionMessages::failedToConstruct(
698 "PeriodicWave", 698 "PeriodicWave",
699 "length of real array (" + String::number(real->length()) 699 "length of real array (" + String::number(real->length())
700 + ") exceeds allowed maximum of 4096")); 700 + ") exceeds allowed maximum of 4096"));
701 return 0; 701 return 0;
702 } 702 }
703 703
704 if (imag->length() > 4096) { 704 if (imag->length() > 4096) {
705 es.throwDOMException( 705 exceptionState.throwDOMException(
706 IndexSizeError, 706 IndexSizeError,
707 ExceptionMessages::failedToConstruct( 707 ExceptionMessages::failedToConstruct(
708 "PeriodicWave", 708 "PeriodicWave",
709 "length of imaginary array (" + String::number(imag->length()) 709 "length of imaginary array (" + String::number(imag->length())
710 + ") exceeds allowed maximum of 4096")); 710 + ") exceeds allowed maximum of 4096"));
711 return 0; 711 return 0;
712 } 712 }
713 713
714 lazyInitialize(); 714 lazyInitialize();
715 return PeriodicWave::create(sampleRate(), real, imag); 715 return PeriodicWave::create(sampleRate(), real, imag);
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 } 1101 }
1102 1102
1103 void AudioContext::decrementActiveSourceCount() 1103 void AudioContext::decrementActiveSourceCount()
1104 { 1104 {
1105 atomicDecrement(&m_activeSourceCount); 1105 atomicDecrement(&m_activeSourceCount);
1106 } 1106 }
1107 1107
1108 } // namespace WebCore 1108 } // namespace WebCore
1109 1109
1110 #endif // ENABLE(WEB_AUDIO) 1110 #endif // ENABLE(WEB_AUDIO)
OLDNEW
« no previous file with comments | « Source/modules/webaudio/AudioBufferSourceNode.cpp ('k') | Source/modules/webaudio/AudioNode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698