Chromium Code Reviews| 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 180 } | 180 } |
| 181 | 181 |
| 182 void AudioContext::lazyInitialize() | 182 void AudioContext::lazyInitialize() |
| 183 { | 183 { |
| 184 if (!m_isInitialized) { | 184 if (!m_isInitialized) { |
| 185 // Don't allow the context to initialize a second time after it's alread y been explicitly uninitialized. | 185 // Don't allow the context to initialize a second time after it's alread y been explicitly uninitialized. |
| 186 ASSERT(!m_isAudioThreadFinished); | 186 ASSERT(!m_isAudioThreadFinished); |
| 187 if (!m_isAudioThreadFinished) { | 187 if (!m_isAudioThreadFinished) { |
| 188 if (m_destinationNode.get()) { | 188 if (m_destinationNode.get()) { |
| 189 m_destinationNode->initialize(); | 189 m_destinationNode->initialize(); |
| 190 | |
|
Raymond Toy
2014/04/01 17:49:49
Don't gratuitously delete (or add) blank lines.
KhNo
2014/04/01 18:25:08
Done.
| |
| 191 if (!isOfflineContext()) { | 190 if (!isOfflineContext()) { |
| 192 // This starts the audio thread. The destination node's prov ideInput() method will now be called repeatedly to render audio. | 191 // This starts the audio thread. The destination node's prov ideInput() method will now be called repeatedly to render audio. |
| 193 // Each time provideInput() is called, a portion of the audi o stream is rendered. Let's call this time period a "render quantum". | 192 // Each time provideInput() is called, a portion of the audi o stream is rendered. Let's call this time period a "render quantum". |
| 194 // NOTE: for now default AudioContext does not need an expli cit startRendering() call from JavaScript. | 193 // NOTE: for now default AudioContext does not need an expli cit startRendering() call from JavaScript. |
| 195 // We may want to consider requiring it for symmetry with Of flineAudioContext. | 194 // We may want to consider requiring it for symmetry with Of flineAudioContext. |
| 196 m_destinationNode->startRendering(); | 195 m_destinationNode->startRendering(); |
| 197 ++s_hardwareContextCount; | 196 ++s_hardwareContextCount; |
| 198 } | 197 } |
| 199 | 198 |
| 199 m_isInitialized = true; | |
| 200 } | 200 } |
| 201 m_isInitialized = true; | |
|
Raymond Toy
2014/04/01 17:49:49
Why is this moved up?
KhNo
2014/04/01 18:25:08
It should be inside if (m_destinationNode.get()) {
Raymond Toy
2014/04/01 20:20:30
Ah. So it's because the destination node is create
| |
| 202 } | 201 } |
| 203 } | 202 } |
| 204 } | 203 } |
| 205 | 204 |
| 206 void AudioContext::clear() | 205 void AudioContext::clear() |
| 207 { | 206 { |
| 208 // We have to release our reference to the destination node before the conte xt will ever be deleted since the destination node holds a reference to the cont ext. | 207 // We have to release our reference to the destination node before the conte xt will ever be deleted since the destination node holds a reference to the cont ext. |
| 209 if (m_destinationNode) | 208 if (m_destinationNode) |
| 210 m_destinationNode.clear(); | 209 m_destinationNode.clear(); |
| 211 | 210 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 338 exceptionState.throwDOMException( | 337 exceptionState.throwDOMException( |
| 339 SyntaxError, | 338 SyntaxError, |
| 340 "invalid ArrayBuffer for audioData."); | 339 "invalid ArrayBuffer for audioData."); |
| 341 return; | 340 return; |
| 342 } | 341 } |
| 343 m_audioDecoder.decodeAsync(audioData, sampleRate(), successCallback, errorCa llback); | 342 m_audioDecoder.decodeAsync(audioData, sampleRate(), successCallback, errorCa llback); |
| 344 } | 343 } |
| 345 | 344 |
| 346 PassRefPtr<AudioBufferSourceNode> AudioContext::createBufferSource() | 345 PassRefPtr<AudioBufferSourceNode> AudioContext::createBufferSource() |
| 347 { | 346 { |
| 348 ASSERT(isMainThread()); | 347 ASSERT(isMainThread()); |
|
Raymond Toy
2014/04/01 17:49:49
Should the ASSERT be moved to lazyInitialize?
KhNo
2014/04/01 18:25:08
It couldn't. Those function can be called internal
Raymond Toy
2014/04/01 20:20:30
Ok. Same could be said for lazyInitialize. Now som
| |
| 349 lazyInitialize(); | |
| 350 RefPtr<AudioBufferSourceNode> node = AudioBufferSourceNode::create(this, m_d estinationNode->sampleRate()); | 348 RefPtr<AudioBufferSourceNode> node = AudioBufferSourceNode::create(this, m_d estinationNode->sampleRate()); |
| 351 | 349 |
| 352 // Because this is an AudioScheduledSourceNode, the context keeps a referenc e until it has finished playing. | 350 // Because this is an AudioScheduledSourceNode, the context keeps a referenc e until it has finished playing. |
| 353 // When this happens, AudioScheduledSourceNode::finish() calls AudioContext: :notifyNodeFinishedProcessing(). | 351 // When this happens, AudioScheduledSourceNode::finish() calls AudioContext: :notifyNodeFinishedProcessing(). |
| 354 refNode(node.get()); | 352 refNode(node.get()); |
| 355 | 353 |
| 356 return node; | 354 return node; |
| 357 } | 355 } |
| 358 | 356 |
| 359 PassRefPtr<MediaElementAudioSourceNode> AudioContext::createMediaElementSource(H TMLMediaElement* mediaElement, ExceptionState& exceptionState) | 357 PassRefPtr<MediaElementAudioSourceNode> AudioContext::createMediaElementSource(H TMLMediaElement* mediaElement, ExceptionState& exceptionState) |
| 360 { | 358 { |
| 359 ASSERT(isMainThread()); | |
| 361 if (!mediaElement) { | 360 if (!mediaElement) { |
| 362 exceptionState.throwDOMException( | 361 exceptionState.throwDOMException( |
| 363 InvalidStateError, | 362 InvalidStateError, |
| 364 "invalid HTMLMedialElement."); | 363 "invalid HTMLMedialElement."); |
| 365 return nullptr; | 364 return nullptr; |
| 366 } | 365 } |
| 367 | 366 |
| 368 ASSERT(isMainThread()); | |
|
Raymond Toy
2014/04/01 17:49:49
This ASSERT should probably not have been removed.
KhNo
2014/04/01 18:25:08
It doesn't removed, Just move to top of function s
| |
| 369 lazyInitialize(); | |
| 370 | |
| 371 // First check if this media element already has a source node. | 367 // First check if this media element already has a source node. |
| 372 if (mediaElement->audioSourceNode()) { | 368 if (mediaElement->audioSourceNode()) { |
| 373 exceptionState.throwDOMException( | 369 exceptionState.throwDOMException( |
| 374 InvalidStateError, | 370 InvalidStateError, |
| 375 "invalid HTMLMediaElement."); | 371 "invalid HTMLMediaElement."); |
| 376 return nullptr; | 372 return nullptr; |
| 377 } | 373 } |
| 378 | 374 |
| 379 RefPtr<MediaElementAudioSourceNode> node = MediaElementAudioSourceNode::crea te(this, mediaElement); | 375 RefPtr<MediaElementAudioSourceNode> node = MediaElementAudioSourceNode::crea te(this, mediaElement); |
| 380 | 376 |
| 381 mediaElement->setAudioSourceNode(node.get()); | 377 mediaElement->setAudioSourceNode(node.get()); |
| 382 | 378 |
| 383 refNode(node.get()); // context keeps reference until node is disconnected | 379 refNode(node.get()); // context keeps reference until node is disconnected |
| 384 return node; | 380 return node; |
| 385 } | 381 } |
| 386 | 382 |
| 387 PassRefPtr<MediaStreamAudioSourceNode> AudioContext::createMediaStreamSource(Med iaStream* mediaStream, ExceptionState& exceptionState) | 383 PassRefPtr<MediaStreamAudioSourceNode> AudioContext::createMediaStreamSource(Med iaStream* mediaStream, ExceptionState& exceptionState) |
| 388 { | 384 { |
| 385 ASSERT(isMainThread()); | |
| 389 if (!mediaStream) { | 386 if (!mediaStream) { |
| 390 exceptionState.throwDOMException( | 387 exceptionState.throwDOMException( |
| 391 InvalidStateError, | 388 InvalidStateError, |
| 392 "invalid MediaStream source"); | 389 "invalid MediaStream source"); |
| 393 return nullptr; | 390 return nullptr; |
| 394 } | 391 } |
| 395 | 392 |
| 396 ASSERT(isMainThread()); | |
|
Raymond Toy
2014/04/01 17:49:49
This ASSERT should not have been removed.
KhNo
2014/04/01 18:25:08
ditto
| |
| 397 lazyInitialize(); | |
| 398 | |
| 399 MediaStreamTrackVector audioTracks = mediaStream->getAudioTracks(); | 393 MediaStreamTrackVector audioTracks = mediaStream->getAudioTracks(); |
| 400 if (audioTracks.isEmpty()) { | 394 if (audioTracks.isEmpty()) { |
| 401 exceptionState.throwDOMException( | 395 exceptionState.throwDOMException( |
| 402 InvalidStateError, | 396 InvalidStateError, |
| 403 "MediaStream has no audio track"); | 397 "MediaStream has no audio track"); |
| 404 return nullptr; | 398 return nullptr; |
| 405 } | 399 } |
| 406 | 400 |
| 407 // Use the first audio track in the media stream. | 401 // Use the first audio track in the media stream. |
| 408 RefPtr<MediaStreamTrack> audioTrack = audioTracks[0]; | 402 RefPtr<MediaStreamTrack> audioTrack = audioTracks[0]; |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 436 | 430 |
| 437 PassRefPtr<ScriptProcessorNode> AudioContext::createScriptProcessor(size_t buffe rSize, size_t numberOfInputChannels, ExceptionState& exceptionState) | 431 PassRefPtr<ScriptProcessorNode> AudioContext::createScriptProcessor(size_t buffe rSize, size_t numberOfInputChannels, ExceptionState& exceptionState) |
| 438 { | 432 { |
| 439 // Set number of output channels to stereo by default. | 433 // Set number of output channels to stereo by default. |
| 440 return createScriptProcessor(bufferSize, numberOfInputChannels, 2, exception State); | 434 return createScriptProcessor(bufferSize, numberOfInputChannels, 2, exception State); |
| 441 } | 435 } |
| 442 | 436 |
| 443 PassRefPtr<ScriptProcessorNode> AudioContext::createScriptProcessor(size_t buffe rSize, size_t numberOfInputChannels, size_t numberOfOutputChannels, ExceptionSta te& exceptionState) | 437 PassRefPtr<ScriptProcessorNode> AudioContext::createScriptProcessor(size_t buffe rSize, size_t numberOfInputChannels, size_t numberOfOutputChannels, ExceptionSta te& exceptionState) |
| 444 { | 438 { |
| 445 ASSERT(isMainThread()); | 439 ASSERT(isMainThread()); |
| 446 lazyInitialize(); | |
| 447 RefPtr<ScriptProcessorNode> node = ScriptProcessorNode::create(this, m_desti nationNode->sampleRate(), bufferSize, numberOfInputChannels, numberOfOutputChann els); | 440 RefPtr<ScriptProcessorNode> node = ScriptProcessorNode::create(this, m_desti nationNode->sampleRate(), bufferSize, numberOfInputChannels, numberOfOutputChann els); |
| 448 | 441 |
| 449 if (!node.get()) { | 442 if (!node.get()) { |
| 450 if (!numberOfInputChannels && !numberOfOutputChannels) { | 443 if (!numberOfInputChannels && !numberOfOutputChannels) { |
| 451 exceptionState.throwDOMException( | 444 exceptionState.throwDOMException( |
| 452 IndexSizeError, | 445 IndexSizeError, |
| 453 "number of input channels and output channels cannot both be zer o."); | 446 "number of input channels and output channels cannot both be zer o."); |
| 454 } else if (numberOfInputChannels > AudioContext::maxNumberOfChannels()) { | 447 } else if (numberOfInputChannels > AudioContext::maxNumberOfChannels()) { |
| 455 exceptionState.throwDOMException( | 448 exceptionState.throwDOMException( |
| 456 IndexSizeError, | 449 IndexSizeError, |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 472 return nullptr; | 465 return nullptr; |
| 473 } | 466 } |
| 474 | 467 |
| 475 refNode(node.get()); // context keeps reference until we stop making javascr ipt rendering callbacks | 468 refNode(node.get()); // context keeps reference until we stop making javascr ipt rendering callbacks |
| 476 return node; | 469 return node; |
| 477 } | 470 } |
| 478 | 471 |
| 479 PassRefPtr<BiquadFilterNode> AudioContext::createBiquadFilter() | 472 PassRefPtr<BiquadFilterNode> AudioContext::createBiquadFilter() |
| 480 { | 473 { |
| 481 ASSERT(isMainThread()); | 474 ASSERT(isMainThread()); |
| 482 lazyInitialize(); | |
| 483 return BiquadFilterNode::create(this, m_destinationNode->sampleRate()); | 475 return BiquadFilterNode::create(this, m_destinationNode->sampleRate()); |
| 484 } | 476 } |
| 485 | 477 |
| 486 PassRefPtr<WaveShaperNode> AudioContext::createWaveShaper() | 478 PassRefPtr<WaveShaperNode> AudioContext::createWaveShaper() |
| 487 { | 479 { |
| 488 ASSERT(isMainThread()); | 480 ASSERT(isMainThread()); |
| 489 lazyInitialize(); | |
| 490 return WaveShaperNode::create(this); | 481 return WaveShaperNode::create(this); |
| 491 } | 482 } |
| 492 | 483 |
| 493 PassRefPtr<PannerNode> AudioContext::createPanner() | 484 PassRefPtr<PannerNode> AudioContext::createPanner() |
| 494 { | 485 { |
| 495 ASSERT(isMainThread()); | 486 ASSERT(isMainThread()); |
| 496 lazyInitialize(); | |
| 497 return PannerNode::create(this, m_destinationNode->sampleRate()); | 487 return PannerNode::create(this, m_destinationNode->sampleRate()); |
| 498 } | 488 } |
| 499 | 489 |
| 500 PassRefPtr<ConvolverNode> AudioContext::createConvolver() | 490 PassRefPtr<ConvolverNode> AudioContext::createConvolver() |
| 501 { | 491 { |
| 502 ASSERT(isMainThread()); | 492 ASSERT(isMainThread()); |
| 503 lazyInitialize(); | |
| 504 return ConvolverNode::create(this, m_destinationNode->sampleRate()); | 493 return ConvolverNode::create(this, m_destinationNode->sampleRate()); |
| 505 } | 494 } |
| 506 | 495 |
| 507 PassRefPtr<DynamicsCompressorNode> AudioContext::createDynamicsCompressor() | 496 PassRefPtr<DynamicsCompressorNode> AudioContext::createDynamicsCompressor() |
| 508 { | 497 { |
| 509 ASSERT(isMainThread()); | 498 ASSERT(isMainThread()); |
| 510 lazyInitialize(); | |
| 511 return DynamicsCompressorNode::create(this, m_destinationNode->sampleRate()) ; | 499 return DynamicsCompressorNode::create(this, m_destinationNode->sampleRate()) ; |
| 512 } | 500 } |
| 513 | 501 |
| 514 PassRefPtr<AnalyserNode> AudioContext::createAnalyser() | 502 PassRefPtr<AnalyserNode> AudioContext::createAnalyser() |
| 515 { | 503 { |
| 516 ASSERT(isMainThread()); | 504 ASSERT(isMainThread()); |
| 517 lazyInitialize(); | |
| 518 return AnalyserNode::create(this, m_destinationNode->sampleRate()); | 505 return AnalyserNode::create(this, m_destinationNode->sampleRate()); |
| 519 } | 506 } |
| 520 | 507 |
| 521 PassRefPtr<GainNode> AudioContext::createGain() | 508 PassRefPtr<GainNode> AudioContext::createGain() |
| 522 { | 509 { |
| 523 ASSERT(isMainThread()); | 510 ASSERT(isMainThread()); |
| 524 lazyInitialize(); | |
| 525 return GainNode::create(this, m_destinationNode->sampleRate()); | 511 return GainNode::create(this, m_destinationNode->sampleRate()); |
| 526 } | 512 } |
| 527 | 513 |
| 528 PassRefPtr<DelayNode> AudioContext::createDelay(ExceptionState& exceptionState) | 514 PassRefPtr<DelayNode> AudioContext::createDelay(ExceptionState& exceptionState) |
| 529 { | 515 { |
| 530 const double defaultMaxDelayTime = 1; | 516 const double defaultMaxDelayTime = 1; |
| 531 return createDelay(defaultMaxDelayTime, exceptionState); | 517 return createDelay(defaultMaxDelayTime, exceptionState); |
| 532 } | 518 } |
| 533 | 519 |
| 534 PassRefPtr<DelayNode> AudioContext::createDelay(double maxDelayTime, ExceptionSt ate& exceptionState) | 520 PassRefPtr<DelayNode> AudioContext::createDelay(double maxDelayTime, ExceptionSt ate& exceptionState) |
| 535 { | 521 { |
| 536 ASSERT(isMainThread()); | 522 ASSERT(isMainThread()); |
| 537 lazyInitialize(); | |
| 538 RefPtr<DelayNode> node = DelayNode::create(this, m_destinationNode->sampleRa te(), maxDelayTime, exceptionState); | 523 RefPtr<DelayNode> node = DelayNode::create(this, m_destinationNode->sampleRa te(), maxDelayTime, exceptionState); |
| 539 if (exceptionState.hadException()) | 524 if (exceptionState.hadException()) |
| 540 return nullptr; | 525 return nullptr; |
| 541 return node; | 526 return node; |
| 542 } | 527 } |
| 543 | 528 |
| 544 PassRefPtr<ChannelSplitterNode> AudioContext::createChannelSplitter(ExceptionSta te& exceptionState) | 529 PassRefPtr<ChannelSplitterNode> AudioContext::createChannelSplitter(ExceptionSta te& exceptionState) |
| 545 { | 530 { |
| 546 const unsigned ChannelSplitterDefaultNumberOfOutputs = 6; | 531 const unsigned ChannelSplitterDefaultNumberOfOutputs = 6; |
| 547 return createChannelSplitter(ChannelSplitterDefaultNumberOfOutputs, exceptio nState); | 532 return createChannelSplitter(ChannelSplitterDefaultNumberOfOutputs, exceptio nState); |
| 548 } | 533 } |
| 549 | 534 |
| 550 PassRefPtr<ChannelSplitterNode> AudioContext::createChannelSplitter(size_t numbe rOfOutputs, ExceptionState& exceptionState) | 535 PassRefPtr<ChannelSplitterNode> AudioContext::createChannelSplitter(size_t numbe rOfOutputs, ExceptionState& exceptionState) |
| 551 { | 536 { |
| 552 ASSERT(isMainThread()); | 537 ASSERT(isMainThread()); |
| 553 lazyInitialize(); | |
| 554 | |
| 555 RefPtr<ChannelSplitterNode> node = ChannelSplitterNode::create(this, m_desti nationNode->sampleRate(), numberOfOutputs); | 538 RefPtr<ChannelSplitterNode> node = ChannelSplitterNode::create(this, m_desti nationNode->sampleRate(), numberOfOutputs); |
| 556 | 539 |
| 557 if (!node.get()) { | 540 if (!node.get()) { |
| 558 exceptionState.throwDOMException( | 541 exceptionState.throwDOMException( |
| 559 IndexSizeError, | 542 IndexSizeError, |
| 560 "number of outputs (" + String::number(numberOfOutputs) | 543 "number of outputs (" + String::number(numberOfOutputs) |
| 561 + ") must be between 1 and " | 544 + ") must be between 1 and " |
| 562 + String::number(AudioContext::maxNumberOfChannels()) + "."); | 545 + String::number(AudioContext::maxNumberOfChannels()) + "."); |
| 563 return nullptr; | 546 return nullptr; |
| 564 } | 547 } |
| 565 | 548 |
| 566 return node; | 549 return node; |
| 567 } | 550 } |
| 568 | 551 |
| 569 PassRefPtr<ChannelMergerNode> AudioContext::createChannelMerger(ExceptionState& exceptionState) | 552 PassRefPtr<ChannelMergerNode> AudioContext::createChannelMerger(ExceptionState& exceptionState) |
| 570 { | 553 { |
| 571 const unsigned ChannelMergerDefaultNumberOfInputs = 6; | 554 const unsigned ChannelMergerDefaultNumberOfInputs = 6; |
| 572 return createChannelMerger(ChannelMergerDefaultNumberOfInputs, exceptionStat e); | 555 return createChannelMerger(ChannelMergerDefaultNumberOfInputs, exceptionStat e); |
| 573 } | 556 } |
| 574 | 557 |
| 575 PassRefPtr<ChannelMergerNode> AudioContext::createChannelMerger(size_t numberOfI nputs, ExceptionState& exceptionState) | 558 PassRefPtr<ChannelMergerNode> AudioContext::createChannelMerger(size_t numberOfI nputs, ExceptionState& exceptionState) |
| 576 { | 559 { |
| 577 ASSERT(isMainThread()); | 560 ASSERT(isMainThread()); |
| 578 lazyInitialize(); | |
| 579 | |
| 580 RefPtr<ChannelMergerNode> node = ChannelMergerNode::create(this, m_destinati onNode->sampleRate(), numberOfInputs); | 561 RefPtr<ChannelMergerNode> node = ChannelMergerNode::create(this, m_destinati onNode->sampleRate(), numberOfInputs); |
| 581 | 562 |
| 582 if (!node.get()) { | 563 if (!node.get()) { |
| 583 exceptionState.throwDOMException( | 564 exceptionState.throwDOMException( |
| 584 IndexSizeError, | 565 IndexSizeError, |
| 585 "number of inputs (" + String::number(numberOfInputs) | 566 "number of inputs (" + String::number(numberOfInputs) |
| 586 + ") must be between 1 and " | 567 + ") must be between 1 and " |
| 587 + String::number(AudioContext::maxNumberOfChannels()) + "."); | 568 + String::number(AudioContext::maxNumberOfChannels()) + "."); |
| 588 return nullptr; | 569 return nullptr; |
| 589 } | 570 } |
| 590 | 571 |
| 591 return node; | 572 return node; |
| 592 } | 573 } |
| 593 | 574 |
| 594 PassRefPtr<OscillatorNode> AudioContext::createOscillator() | 575 PassRefPtr<OscillatorNode> AudioContext::createOscillator() |
| 595 { | 576 { |
| 596 ASSERT(isMainThread()); | 577 ASSERT(isMainThread()); |
| 597 lazyInitialize(); | |
| 598 | |
| 599 RefPtr<OscillatorNode> node = OscillatorNode::create(this, m_destinationNode ->sampleRate()); | 578 RefPtr<OscillatorNode> node = OscillatorNode::create(this, m_destinationNode ->sampleRate()); |
| 600 | 579 |
| 601 // Because this is an AudioScheduledSourceNode, the context keeps a referenc e until it has finished playing. | 580 // Because this is an AudioScheduledSourceNode, the context keeps a referenc e until it has finished playing. |
| 602 // When this happens, AudioScheduledSourceNode::finish() calls AudioContext: :notifyNodeFinishedProcessing(). | 581 // When this happens, AudioScheduledSourceNode::finish() calls AudioContext: :notifyNodeFinishedProcessing(). |
| 603 refNode(node.get()); | 582 refNode(node.get()); |
| 604 | 583 |
| 605 return node; | 584 return node; |
| 606 } | 585 } |
| 607 | 586 |
| 608 PassRefPtr<PeriodicWave> AudioContext::createPeriodicWave(Float32Array* real, Fl oat32Array* imag, ExceptionState& exceptionState) | 587 PassRefPtr<PeriodicWave> AudioContext::createPeriodicWave(Float32Array* real, Fl oat32Array* imag, ExceptionState& exceptionState) |
| 609 { | 588 { |
| 610 ASSERT(isMainThread()); | 589 ASSERT(isMainThread()); |
| 611 | |
|
Raymond Toy
2014/04/01 17:49:49
Don't gratuitously delete (or add) blank lines.
KhNo
2014/04/01 18:25:08
Done.
| |
| 612 if (!real) { | 590 if (!real) { |
| 613 exceptionState.throwDOMException( | 591 exceptionState.throwDOMException( |
| 614 SyntaxError, | 592 SyntaxError, |
| 615 "invalid real array"); | 593 "invalid real array"); |
| 616 return nullptr; | 594 return nullptr; |
| 617 } | 595 } |
| 618 | 596 |
| 619 if (!imag) { | 597 if (!imag) { |
| 620 exceptionState.throwDOMException( | 598 exceptionState.throwDOMException( |
| 621 SyntaxError, | 599 SyntaxError, |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 641 } | 619 } |
| 642 | 620 |
| 643 if (imag->length() > 4096) { | 621 if (imag->length() > 4096) { |
| 644 exceptionState.throwDOMException( | 622 exceptionState.throwDOMException( |
| 645 IndexSizeError, | 623 IndexSizeError, |
| 646 "length of imaginary array (" + String::number(imag->length()) | 624 "length of imaginary array (" + String::number(imag->length()) |
| 647 + ") exceeds allowed maximum of 4096"); | 625 + ") exceeds allowed maximum of 4096"); |
| 648 return nullptr; | 626 return nullptr; |
| 649 } | 627 } |
| 650 | 628 |
| 651 lazyInitialize(); | |
| 652 return PeriodicWave::create(sampleRate(), real, imag); | 629 return PeriodicWave::create(sampleRate(), real, imag); |
| 653 } | 630 } |
| 654 | 631 |
| 655 void AudioContext::notifyNodeFinishedProcessing(AudioNode* node) | 632 void AudioContext::notifyNodeFinishedProcessing(AudioNode* node) |
| 656 { | 633 { |
| 657 ASSERT(isAudioThread()); | 634 ASSERT(isAudioThread()); |
| 658 m_finishedNodes.append(node); | 635 m_finishedNodes.append(node); |
| 659 } | 636 } |
| 660 | 637 |
| 661 void AudioContext::derefFinishedSourceNodes() | 638 void AudioContext::derefFinishedSourceNodes() |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1038 } | 1015 } |
| 1039 | 1016 |
| 1040 void AudioContext::decrementActiveSourceCount() | 1017 void AudioContext::decrementActiveSourceCount() |
| 1041 { | 1018 { |
| 1042 atomicDecrement(&m_activeSourceCount); | 1019 atomicDecrement(&m_activeSourceCount); |
| 1043 } | 1020 } |
| 1044 | 1021 |
| 1045 } // namespace WebCore | 1022 } // namespace WebCore |
| 1046 | 1023 |
| 1047 #endif // ENABLE(WEB_AUDIO) | 1024 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |