| OLD | NEW |
| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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
& exceptionState) | 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 exceptionState.throwDOMException( | 96 exceptionState.throwDOMException( |
| 97 SyntaxError, | 97 SyntaxError, |
| 98 ExceptionMessages::failedToConstruct( | 98 "number of hardware contexts reached maximum (" + String::number(Max
HardwareContexts) + ")."); |
| 99 "AudioContext", | |
| 100 "number of hardware contexts reached maximum (" + String::number
(MaxHardwareContexts) + ").")); | |
| 101 return 0; | 99 return 0; |
| 102 } | 100 } |
| 103 | 101 |
| 104 RefPtr<AudioContext> audioContext(adoptRef(new AudioContext(&document))); | 102 RefPtr<AudioContext> audioContext(adoptRef(new AudioContext(&document))); |
| 105 audioContext->suspendIfNeeded(); | 103 audioContext->suspendIfNeeded(); |
| 106 return audioContext.release(); | 104 return audioContext.release(); |
| 107 } | 105 } |
| 108 | 106 |
| 109 PassRefPtr<AudioContext> AudioContext::create(Document& document, unsigned numbe
rOfChannels, size_t numberOfFrames, float sampleRate, ExceptionState& exceptionS
tate) | 107 PassRefPtr<AudioContext> AudioContext::create(Document& document, unsigned numbe
rOfChannels, size_t numberOfFrames, float sampleRate, ExceptionState& exceptionS
tate) |
| 110 { | 108 { |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 callOnMainThread(stopDispatch, this); | 294 callOnMainThread(stopDispatch, this); |
| 297 } | 295 } |
| 298 | 296 |
| 299 PassRefPtr<AudioBuffer> AudioContext::createBuffer(unsigned numberOfChannels, si
ze_t numberOfFrames, float sampleRate, ExceptionState& exceptionState) | 297 PassRefPtr<AudioBuffer> AudioContext::createBuffer(unsigned numberOfChannels, si
ze_t numberOfFrames, float sampleRate, ExceptionState& exceptionState) |
| 300 { | 298 { |
| 301 RefPtr<AudioBuffer> audioBuffer = AudioBuffer::create(numberOfChannels, numb
erOfFrames, sampleRate); | 299 RefPtr<AudioBuffer> audioBuffer = AudioBuffer::create(numberOfChannels, numb
erOfFrames, sampleRate); |
| 302 if (!audioBuffer.get()) { | 300 if (!audioBuffer.get()) { |
| 303 if (numberOfChannels > AudioContext::maxNumberOfChannels()) { | 301 if (numberOfChannels > AudioContext::maxNumberOfChannels()) { |
| 304 exceptionState.throwDOMException( | 302 exceptionState.throwDOMException( |
| 305 NotSupportedError, | 303 NotSupportedError, |
| 306 ExceptionMessages::failedToConstruct( | 304 "requested number of channels (" + String::number(numberOfChanne
ls) + ") exceeds maximum (" + String::number(AudioContext::maxNumberOfChannels()
) + ")"); |
| 307 "AudioBuffer", | |
| 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()) { | 305 } else if (sampleRate < AudioBuffer::minAllowedSampleRate() || sampleRat
e > AudioBuffer::maxAllowedSampleRate()) { |
| 310 exceptionState.throwDOMException( | 306 exceptionState.throwDOMException( |
| 311 NotSupportedError, | 307 NotSupportedError, |
| 312 ExceptionMessages::failedToConstruct( | 308 "requested sample rate (" + String::number(sampleRate) |
| 313 "AudioBuffer", | 309 + ") does not lie in the allowed range of " |
| 314 "requested sample rate (" + String::number(sampleRate) | 310 + String::number(AudioBuffer::minAllowedSampleRate()) |
| 315 + ") does not lie in the allowed range of " | 311 + "-" + String::number(AudioBuffer::maxAllowedSampleRate()) + "
Hz"); |
| 316 + String::number(AudioBuffer::minAllowedSampleRate()) | |
| 317 + "-" + String::number(AudioBuffer::maxAllowedSampleRate())
+ " Hz")); | |
| 318 } else if (!numberOfFrames) { | 312 } else if (!numberOfFrames) { |
| 319 exceptionState.throwDOMException( | 313 exceptionState.throwDOMException( |
| 320 NotSupportedError, | 314 NotSupportedError, |
| 321 ExceptionMessages::failedToConstruct( | 315 "number of frames must be greater than 0."); |
| 322 "AudioBuffer", | |
| 323 "number of frames must be greater than 0.")); | |
| 324 } else { | 316 } else { |
| 325 exceptionState.throwDOMException( | 317 exceptionState.throwDOMException( |
| 326 NotSupportedError, | 318 NotSupportedError, |
| 327 ExceptionMessages::failedToConstruct( | 319 "unable to create buffer of " + String::number(numberOfChannels) |
| 328 "AudioBuffer", | 320 + " channel(s) of " + String::number(numberOfFrames) |
| 329 "unable to create buffer of " + String::number(numberOfChann
els) | 321 + " frames each."); |
| 330 + " channel(s) of " + String::number(numberOfFrames) | |
| 331 + " frames each.")); | |
| 332 } | 322 } |
| 333 return 0; | 323 return 0; |
| 334 } | 324 } |
| 335 | 325 |
| 336 return audioBuffer; | 326 return audioBuffer; |
| 337 } | 327 } |
| 338 | 328 |
| 339 PassRefPtr<AudioBuffer> AudioContext::createBuffer(ArrayBuffer* arrayBuffer, boo
l mixToMono, ExceptionState& exceptionState) | 329 PassRefPtr<AudioBuffer> AudioContext::createBuffer(ArrayBuffer* arrayBuffer, boo
l mixToMono, ExceptionState& exceptionState) |
| 340 { | 330 { |
| 341 ASSERT(arrayBuffer); | 331 ASSERT(arrayBuffer); |
| 342 if (!arrayBuffer) { | 332 if (!arrayBuffer) { |
| 343 exceptionState.throwDOMException( | 333 exceptionState.throwDOMException( |
| 344 SyntaxError, | 334 SyntaxError, |
| 345 ExceptionMessages::failedToConstruct( | 335 "invalid ArrayBuffer."); |
| 346 "AudioBuffer", | |
| 347 "invalid ArrayBuffer.")); | |
| 348 return 0; | 336 return 0; |
| 349 } | 337 } |
| 350 | 338 |
| 351 RefPtr<AudioBuffer> audioBuffer = AudioBuffer::createFromAudioFileData(array
Buffer->data(), arrayBuffer->byteLength(), mixToMono, sampleRate()); | 339 RefPtr<AudioBuffer> audioBuffer = AudioBuffer::createFromAudioFileData(array
Buffer->data(), arrayBuffer->byteLength(), mixToMono, sampleRate()); |
| 352 if (!audioBuffer.get()) { | 340 if (!audioBuffer.get()) { |
| 353 exceptionState.throwDOMException( | 341 exceptionState.throwDOMException( |
| 354 SyntaxError, | 342 SyntaxError, |
| 355 ExceptionMessages::failedToConstruct( | 343 "invalid audio data in ArrayBuffer."); |
| 356 "AudioBuffer", | |
| 357 "invalid audio data in ArrayBuffer.")); | |
| 358 return 0; | 344 return 0; |
| 359 } | 345 } |
| 360 | 346 |
| 361 return audioBuffer; | 347 return audioBuffer; |
| 362 } | 348 } |
| 363 | 349 |
| 364 void AudioContext::decodeAudioData(ArrayBuffer* audioData, PassOwnPtr<AudioBuffe
rCallback> successCallback, PassOwnPtr<AudioBufferCallback> errorCallback, Excep
tionState& exceptionState) | 350 void AudioContext::decodeAudioData(ArrayBuffer* audioData, PassOwnPtr<AudioBuffe
rCallback> successCallback, PassOwnPtr<AudioBufferCallback> errorCallback, Excep
tionState& exceptionState) |
| 365 { | 351 { |
| 366 if (!audioData) { | 352 if (!audioData) { |
| 367 exceptionState.throwDOMException( | 353 exceptionState.throwDOMException( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 383 refNode(node.get()); | 369 refNode(node.get()); |
| 384 | 370 |
| 385 return node; | 371 return node; |
| 386 } | 372 } |
| 387 | 373 |
| 388 PassRefPtr<MediaElementAudioSourceNode> AudioContext::createMediaElementSource(H
TMLMediaElement* mediaElement, ExceptionState& exceptionState) | 374 PassRefPtr<MediaElementAudioSourceNode> AudioContext::createMediaElementSource(H
TMLMediaElement* mediaElement, ExceptionState& exceptionState) |
| 389 { | 375 { |
| 390 if (!mediaElement) { | 376 if (!mediaElement) { |
| 391 exceptionState.throwDOMException( | 377 exceptionState.throwDOMException( |
| 392 InvalidStateError, | 378 InvalidStateError, |
| 393 ExceptionMessages::failedToConstruct( | 379 "invalid HTMLMedialElement."); |
| 394 "MediaElementAudioSourceNode", | |
| 395 "invalid HTMLMedialElement.")); | |
| 396 return 0; | 380 return 0; |
| 397 } | 381 } |
| 398 | 382 |
| 399 ASSERT(isMainThread()); | 383 ASSERT(isMainThread()); |
| 400 lazyInitialize(); | 384 lazyInitialize(); |
| 401 | 385 |
| 402 // First check if this media element already has a source node. | 386 // First check if this media element already has a source node. |
| 403 if (mediaElement->audioSourceNode()) { | 387 if (mediaElement->audioSourceNode()) { |
| 404 exceptionState.throwDOMException( | 388 exceptionState.throwDOMException( |
| 405 InvalidStateError, | 389 InvalidStateError, |
| 406 ExceptionMessages::failedToConstruct( | 390 "invalid HTMLMediaElement."); |
| 407 "MediaElementAudioSourceNode", | |
| 408 "invalid HTMLMediaElement.")); | |
| 409 return 0; | 391 return 0; |
| 410 } | 392 } |
| 411 | 393 |
| 412 RefPtr<MediaElementAudioSourceNode> node = MediaElementAudioSourceNode::crea
te(this, mediaElement); | 394 RefPtr<MediaElementAudioSourceNode> node = MediaElementAudioSourceNode::crea
te(this, mediaElement); |
| 413 | 395 |
| 414 mediaElement->setAudioSourceNode(node.get()); | 396 mediaElement->setAudioSourceNode(node.get()); |
| 415 | 397 |
| 416 refNode(node.get()); // context keeps reference until node is disconnected | 398 refNode(node.get()); // context keeps reference until node is disconnected |
| 417 return node; | 399 return node; |
| 418 } | 400 } |
| 419 | 401 |
| 420 PassRefPtr<MediaStreamAudioSourceNode> AudioContext::createMediaStreamSource(Med
iaStream* mediaStream, ExceptionState& exceptionState) | 402 PassRefPtr<MediaStreamAudioSourceNode> AudioContext::createMediaStreamSource(Med
iaStream* mediaStream, ExceptionState& exceptionState) |
| 421 { | 403 { |
| 422 if (!mediaStream) { | 404 if (!mediaStream) { |
| 423 exceptionState.throwDOMException( | 405 exceptionState.throwDOMException( |
| 424 InvalidStateError, | 406 InvalidStateError, |
| 425 ExceptionMessages::failedToConstruct( | 407 "invalid MediaStream source"); |
| 426 "MediaStreamAudioSourceNode", | |
| 427 "invalid MediaStream source")); | |
| 428 return 0; | 408 return 0; |
| 429 } | 409 } |
| 430 | 410 |
| 431 ASSERT(isMainThread()); | 411 ASSERT(isMainThread()); |
| 432 lazyInitialize(); | 412 lazyInitialize(); |
| 433 | 413 |
| 434 AudioSourceProvider* provider = 0; | 414 AudioSourceProvider* provider = 0; |
| 435 | 415 |
| 436 MediaStreamTrackVector audioTracks = mediaStream->getAudioTracks(); | 416 MediaStreamTrackVector audioTracks = mediaStream->getAudioTracks(); |
| 437 RefPtr<MediaStreamTrack> audioTrack; | 417 RefPtr<MediaStreamTrack> audioTrack; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 PassRefPtr<ScriptProcessorNode> AudioContext::createScriptProcessor(size_t buffe
rSize, size_t numberOfInputChannels, size_t numberOfOutputChannels, ExceptionSta
te& exceptionState) | 462 PassRefPtr<ScriptProcessorNode> AudioContext::createScriptProcessor(size_t buffe
rSize, size_t numberOfInputChannels, size_t numberOfOutputChannels, ExceptionSta
te& exceptionState) |
| 483 { | 463 { |
| 484 ASSERT(isMainThread()); | 464 ASSERT(isMainThread()); |
| 485 lazyInitialize(); | 465 lazyInitialize(); |
| 486 RefPtr<ScriptProcessorNode> node = ScriptProcessorNode::create(this, m_desti
nationNode->sampleRate(), bufferSize, numberOfInputChannels, numberOfOutputChann
els); | 466 RefPtr<ScriptProcessorNode> node = ScriptProcessorNode::create(this, m_desti
nationNode->sampleRate(), bufferSize, numberOfInputChannels, numberOfOutputChann
els); |
| 487 | 467 |
| 488 if (!node.get()) { | 468 if (!node.get()) { |
| 489 if (!numberOfInputChannels && !numberOfOutputChannels) { | 469 if (!numberOfInputChannels && !numberOfOutputChannels) { |
| 490 exceptionState.throwDOMException( | 470 exceptionState.throwDOMException( |
| 491 IndexSizeError, | 471 IndexSizeError, |
| 492 ExceptionMessages::failedToConstruct( | 472 "number of input channels and output channels cannot both be zer
o."); |
| 493 "ScriptProcessorNode", | |
| 494 "number of input channels and output channels cannot both be
zero.")); | |
| 495 } else if (numberOfInputChannels > AudioContext::maxNumberOfChannels())
{ | 473 } else if (numberOfInputChannels > AudioContext::maxNumberOfChannels())
{ |
| 496 exceptionState.throwDOMException( | 474 exceptionState.throwDOMException( |
| 497 IndexSizeError, | 475 IndexSizeError, |
| 498 ExceptionMessages::failedToConstruct( | 476 "number of input channels (" + String::number(numberOfInputChann
els) |
| 499 "ScriptProcessorNode", | 477 + ") exceeds maximum (" |
| 500 "number of input channels (" + String::number(numberOfInputC
hannels) | 478 + String::number(AudioContext::maxNumberOfChannels()) + ")."); |
| 501 + ") exceeds maximum (" | |
| 502 + String::number(AudioContext::maxNumberOfChannels()) + ")."
)); | |
| 503 } else if (numberOfOutputChannels > AudioContext::maxNumberOfChannels())
{ | 479 } else if (numberOfOutputChannels > AudioContext::maxNumberOfChannels())
{ |
| 504 exceptionState.throwDOMException( | 480 exceptionState.throwDOMException( |
| 505 IndexSizeError, | 481 IndexSizeError, |
| 506 ExceptionMessages::failedToConstruct( | 482 "number of output channels (" + String::number(numberOfInputChan
nels) |
| 507 "ScriptProcessorNode", | 483 + ") exceeds maximum (" |
| 508 "number of output channels (" + String::number(numberOfInput
Channels) | 484 + String::number(AudioContext::maxNumberOfChannels()) + ")."); |
| 509 + ") exceeds maximum (" | |
| 510 + String::number(AudioContext::maxNumberOfChannels()) + ")."
)); | |
| 511 } else { | 485 } else { |
| 512 exceptionState.throwDOMException( | 486 exceptionState.throwDOMException( |
| 513 IndexSizeError, | 487 IndexSizeError, |
| 514 ExceptionMessages::failedToConstruct( | 488 "buffer size (" + String::number(bufferSize) |
| 515 "ScriptProcessorNode", | 489 + ") must be a power of two between 256 and 16384."); |
| 516 "buffer size (" + String::number(bufferSize) | |
| 517 + ") must be a power of two between 256 and 16384.")); | |
| 518 } | 490 } |
| 519 return 0; | 491 return 0; |
| 520 } | 492 } |
| 521 | 493 |
| 522 refNode(node.get()); // context keeps reference until we stop making javascr
ipt rendering callbacks | 494 refNode(node.get()); // context keeps reference until we stop making javascr
ipt rendering callbacks |
| 523 return node; | 495 return node; |
| 524 } | 496 } |
| 525 | 497 |
| 526 PassRefPtr<BiquadFilterNode> AudioContext::createBiquadFilter() | 498 PassRefPtr<BiquadFilterNode> AudioContext::createBiquadFilter() |
| 527 { | 499 { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 PassRefPtr<ChannelSplitterNode> AudioContext::createChannelSplitter(size_t numbe
rOfOutputs, ExceptionState& exceptionState) | 569 PassRefPtr<ChannelSplitterNode> AudioContext::createChannelSplitter(size_t numbe
rOfOutputs, ExceptionState& exceptionState) |
| 598 { | 570 { |
| 599 ASSERT(isMainThread()); | 571 ASSERT(isMainThread()); |
| 600 lazyInitialize(); | 572 lazyInitialize(); |
| 601 | 573 |
| 602 RefPtr<ChannelSplitterNode> node = ChannelSplitterNode::create(this, m_desti
nationNode->sampleRate(), numberOfOutputs); | 574 RefPtr<ChannelSplitterNode> node = ChannelSplitterNode::create(this, m_desti
nationNode->sampleRate(), numberOfOutputs); |
| 603 | 575 |
| 604 if (!node.get()) { | 576 if (!node.get()) { |
| 605 exceptionState.throwDOMException( | 577 exceptionState.throwDOMException( |
| 606 IndexSizeError, | 578 IndexSizeError, |
| 607 ExceptionMessages::failedToConstruct( | 579 "number of outputs (" + String::number(numberOfOutputs) |
| 608 "ChannelSplitterNode", | 580 + ") must be between 1 and " |
| 609 "number of outputs (" + String::number(numberOfOutputs) | 581 + String::number(AudioContext::maxNumberOfChannels()) + "."); |
| 610 + ") must be between 1 and " | |
| 611 + String::number(AudioContext::maxNumberOfChannels()) + ".")); | |
| 612 return 0; | 582 return 0; |
| 613 } | 583 } |
| 614 | 584 |
| 615 return node; | 585 return node; |
| 616 } | 586 } |
| 617 | 587 |
| 618 PassRefPtr<ChannelMergerNode> AudioContext::createChannelMerger(ExceptionState&
exceptionState) | 588 PassRefPtr<ChannelMergerNode> AudioContext::createChannelMerger(ExceptionState&
exceptionState) |
| 619 { | 589 { |
| 620 const unsigned ChannelMergerDefaultNumberOfInputs = 6; | 590 const unsigned ChannelMergerDefaultNumberOfInputs = 6; |
| 621 return createChannelMerger(ChannelMergerDefaultNumberOfInputs, exceptionStat
e); | 591 return createChannelMerger(ChannelMergerDefaultNumberOfInputs, exceptionStat
e); |
| 622 } | 592 } |
| 623 | 593 |
| 624 PassRefPtr<ChannelMergerNode> AudioContext::createChannelMerger(size_t numberOfI
nputs, ExceptionState& exceptionState) | 594 PassRefPtr<ChannelMergerNode> AudioContext::createChannelMerger(size_t numberOfI
nputs, ExceptionState& exceptionState) |
| 625 { | 595 { |
| 626 ASSERT(isMainThread()); | 596 ASSERT(isMainThread()); |
| 627 lazyInitialize(); | 597 lazyInitialize(); |
| 628 | 598 |
| 629 RefPtr<ChannelMergerNode> node = ChannelMergerNode::create(this, m_destinati
onNode->sampleRate(), numberOfInputs); | 599 RefPtr<ChannelMergerNode> node = ChannelMergerNode::create(this, m_destinati
onNode->sampleRate(), numberOfInputs); |
| 630 | 600 |
| 631 if (!node.get()) { | 601 if (!node.get()) { |
| 632 exceptionState.throwDOMException( | 602 exceptionState.throwDOMException( |
| 633 IndexSizeError, | 603 IndexSizeError, |
| 634 ExceptionMessages::failedToConstruct( | 604 "number of inputs (" + String::number(numberOfInputs) |
| 635 "ChannelMergerNode", | 605 + ") must be between 1 and " |
| 636 "number of inputs (" + String::number(numberOfInputs) | 606 + String::number(AudioContext::maxNumberOfChannels()) + "."); |
| 637 + ") must be between 1 and " | |
| 638 + String::number(AudioContext::maxNumberOfChannels()) + ".")); | |
| 639 return 0; | 607 return 0; |
| 640 } | 608 } |
| 641 | 609 |
| 642 return node; | 610 return node; |
| 643 } | 611 } |
| 644 | 612 |
| 645 PassRefPtr<OscillatorNode> AudioContext::createOscillator() | 613 PassRefPtr<OscillatorNode> AudioContext::createOscillator() |
| 646 { | 614 { |
| 647 ASSERT(isMainThread()); | 615 ASSERT(isMainThread()); |
| 648 lazyInitialize(); | 616 lazyInitialize(); |
| 649 | 617 |
| 650 RefPtr<OscillatorNode> node = OscillatorNode::create(this, m_destinationNode
->sampleRate()); | 618 RefPtr<OscillatorNode> node = OscillatorNode::create(this, m_destinationNode
->sampleRate()); |
| 651 | 619 |
| 652 // Because this is an AudioScheduledSourceNode, the context keeps a referenc
e until it has finished playing. | 620 // Because this is an AudioScheduledSourceNode, the context keeps a referenc
e until it has finished playing. |
| 653 // When this happens, AudioScheduledSourceNode::finish() calls AudioContext:
:notifyNodeFinishedProcessing(). | 621 // When this happens, AudioScheduledSourceNode::finish() calls AudioContext:
:notifyNodeFinishedProcessing(). |
| 654 refNode(node.get()); | 622 refNode(node.get()); |
| 655 | 623 |
| 656 return node; | 624 return node; |
| 657 } | 625 } |
| 658 | 626 |
| 659 PassRefPtr<PeriodicWave> AudioContext::createPeriodicWave(Float32Array* real, Fl
oat32Array* imag, ExceptionState& exceptionState) | 627 PassRefPtr<PeriodicWave> AudioContext::createPeriodicWave(Float32Array* real, Fl
oat32Array* imag, ExceptionState& exceptionState) |
| 660 { | 628 { |
| 661 ASSERT(isMainThread()); | 629 ASSERT(isMainThread()); |
| 662 | 630 |
| 663 if (!real) { | 631 if (!real) { |
| 664 exceptionState.throwDOMException( | 632 exceptionState.throwDOMException( |
| 665 SyntaxError, | 633 SyntaxError, |
| 666 ExceptionMessages::failedToConstruct( | 634 "invalid real array"); |
| 667 "PeriodicWave", | |
| 668 "invalid real array")); | |
| 669 return 0; | 635 return 0; |
| 670 } | 636 } |
| 671 | 637 |
| 672 if (!imag) { | 638 if (!imag) { |
| 673 exceptionState.throwDOMException( | 639 exceptionState.throwDOMException( |
| 674 SyntaxError, | 640 SyntaxError, |
| 675 ExceptionMessages::failedToConstruct( | 641 "invalid imaginary array"); |
| 676 "PeriodicWave", | |
| 677 "invalid imaginary array")); | |
| 678 return 0; | 642 return 0; |
| 679 } | 643 } |
| 680 | 644 |
| 681 if (real->length() != imag->length()) { | 645 if (real->length() != imag->length()) { |
| 682 exceptionState.throwDOMException( | 646 exceptionState.throwDOMException( |
| 683 IndexSizeError, | 647 IndexSizeError, |
| 684 ExceptionMessages::failedToConstruct( | 648 "length of real array (" + String::number(real->length()) |
| 685 "PeriodicWave", | 649 + ") and length of imaginary array (" + String::number(imag->length
()) |
| 686 "length of real array (" + String::number(real->length()) | 650 + ") must match."); |
| 687 + ") and length of imaginary array (" + String::number(imag->le
ngth()) | |
| 688 + ") must match.")); | |
| 689 return 0; | 651 return 0; |
| 690 } | 652 } |
| 691 | 653 |
| 692 if (real->length() > 4096) { | 654 if (real->length() > 4096) { |
| 693 exceptionState.throwDOMException( | 655 exceptionState.throwDOMException( |
| 694 IndexSizeError, | 656 IndexSizeError, |
| 695 ExceptionMessages::failedToConstruct( | 657 "length of real array (" + String::number(real->length()) |
| 696 "PeriodicWave", | 658 + ") exceeds allowed maximum of 4096"); |
| 697 "length of real array (" + String::number(real->length()) | |
| 698 + ") exceeds allowed maximum of 4096")); | |
| 699 return 0; | 659 return 0; |
| 700 } | 660 } |
| 701 | 661 |
| 702 if (imag->length() > 4096) { | 662 if (imag->length() > 4096) { |
| 703 exceptionState.throwDOMException( | 663 exceptionState.throwDOMException( |
| 704 IndexSizeError, | 664 IndexSizeError, |
| 705 ExceptionMessages::failedToConstruct( | 665 "length of imaginary array (" + String::number(imag->length()) |
| 706 "PeriodicWave", | 666 + ") exceeds allowed maximum of 4096"); |
| 707 "length of imaginary array (" + String::number(imag->length()) | |
| 708 + ") exceeds allowed maximum of 4096")); | |
| 709 return 0; | 667 return 0; |
| 710 } | 668 } |
| 711 | 669 |
| 712 lazyInitialize(); | 670 lazyInitialize(); |
| 713 return PeriodicWave::create(sampleRate(), real, imag); | 671 return PeriodicWave::create(sampleRate(), real, imag); |
| 714 } | 672 } |
| 715 | 673 |
| 716 void AudioContext::notifyNodeFinishedProcessing(AudioNode* node) | 674 void AudioContext::notifyNodeFinishedProcessing(AudioNode* node) |
| 717 { | 675 { |
| 718 ASSERT(isAudioThread()); | 676 ASSERT(isAudioThread()); |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1099 } | 1057 } |
| 1100 | 1058 |
| 1101 void AudioContext::decrementActiveSourceCount() | 1059 void AudioContext::decrementActiveSourceCount() |
| 1102 { | 1060 { |
| 1103 atomicDecrement(&m_activeSourceCount); | 1061 atomicDecrement(&m_activeSourceCount); |
| 1104 } | 1062 } |
| 1105 | 1063 |
| 1106 } // namespace WebCore | 1064 } // namespace WebCore |
| 1107 | 1065 |
| 1108 #endif // ENABLE(WEB_AUDIO) | 1066 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |