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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 = 6; | 89 const unsigned MaxHardwareContexts = 6; |
90 unsigned AudioContext::s_hardwareContextCount = 0; | 90 unsigned AudioContext::s_hardwareContextCount = 0; |
91 | 91 |
92 PassRefPtr<AudioContext> AudioContext::create(Document& document, ExceptionState & exceptionState) | 92 PassRefPtrWillBeRawPtr<AudioContext> AudioContext::create(Document& document, Ex ceptionState& 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 "number of hardware contexts reached maximum (" + String::number(Max HardwareContexts) + ")."); | 98 "number of hardware contexts reached maximum (" + String::number(Max HardwareContexts) + ")."); |
99 return nullptr; | 99 return nullptr; |
100 } | 100 } |
101 | 101 |
102 RefPtr<AudioContext> audioContext(adoptRef(new AudioContext(&document))); | 102 RefPtrWillBeRawPtr<AudioContext> audioContext(adoptRefWillBeThreadSafeRefCou ntedGarbageCollected(new AudioContext(&document))); |
103 audioContext->suspendIfNeeded(); | 103 audioContext->suspendIfNeeded(); |
104 return audioContext.release(); | 104 return audioContext.release(); |
105 } | 105 } |
106 | 106 |
107 // Constructor for rendering to the audio hardware. | 107 // Constructor for rendering to the audio hardware. |
108 AudioContext::AudioContext(Document* document) | 108 AudioContext::AudioContext(Document* document) |
109 : ActiveDOMObject(document) | 109 : ActiveDOMObject(document) |
110 , m_isStopScheduled(false) | 110 , m_isStopScheduled(false) |
111 , m_isCleared(false) | 111 , m_isCleared(false) |
112 , m_isInitialized(false) | 112 , m_isInitialized(false) |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
266 // FIXME: see if there's a more direct way to handle this issue. | 266 // FIXME: see if there's a more direct way to handle this issue. |
267 callOnMainThread(stopDispatch, this); | 267 callOnMainThread(stopDispatch, this); |
268 } | 268 } |
269 | 269 |
270 bool AudioContext::hasPendingActivity() const | 270 bool AudioContext::hasPendingActivity() const |
271 { | 271 { |
272 // According to spec AudioContext must die only after page navigates. | 272 // According to spec AudioContext must die only after page navigates. |
273 return !m_isCleared; | 273 return !m_isCleared; |
274 } | 274 } |
275 | 275 |
276 PassRefPtr<AudioBuffer> AudioContext::createBuffer(unsigned numberOfChannels, si ze_t numberOfFrames, float sampleRate, ExceptionState& exceptionState) | 276 PassRefPtrWillBeRawPtr<AudioBuffer> AudioContext::createBuffer(unsigned numberOf Channels, size_t numberOfFrames, float sampleRate, ExceptionState& exceptionStat e) |
277 { | 277 { |
278 RefPtr<AudioBuffer> audioBuffer = AudioBuffer::create(numberOfChannels, numb erOfFrames, sampleRate); | 278 RefPtrWillBeRawPtr<AudioBuffer> audioBuffer = AudioBuffer::create(numberOfCh annels, numberOfFrames, sampleRate); |
279 if (!audioBuffer.get()) { | 279 if (!audioBuffer.get()) { |
280 if (numberOfChannels > AudioContext::maxNumberOfChannels()) { | 280 if (numberOfChannels > AudioContext::maxNumberOfChannels()) { |
281 exceptionState.throwDOMException( | 281 exceptionState.throwDOMException( |
282 NotSupportedError, | 282 NotSupportedError, |
283 "requested number of channels (" + String::number(numberOfChanne ls) + ") exceeds maximum (" + String::number(AudioContext::maxNumberOfChannels() ) + ")"); | 283 "requested number of channels (" + String::number(numberOfChanne ls) + ") exceeds maximum (" + String::number(AudioContext::maxNumberOfChannels() ) + ")"); |
284 } else if (sampleRate < AudioBuffer::minAllowedSampleRate() || sampleRat e > AudioBuffer::maxAllowedSampleRate()) { | 284 } else if (sampleRate < AudioBuffer::minAllowedSampleRate() || sampleRat e > AudioBuffer::maxAllowedSampleRate()) { |
285 exceptionState.throwDOMException( | 285 exceptionState.throwDOMException( |
286 NotSupportedError, | 286 NotSupportedError, |
287 "requested sample rate (" + String::number(sampleRate) | 287 "requested sample rate (" + String::number(sampleRate) |
288 + ") does not lie in the allowed range of " | 288 + ") does not lie in the allowed range of " |
289 + String::number(AudioBuffer::minAllowedSampleRate()) | 289 + String::number(AudioBuffer::minAllowedSampleRate()) |
290 + "-" + String::number(AudioBuffer::maxAllowedSampleRate()) + " Hz"); | 290 + "-" + String::number(AudioBuffer::maxAllowedSampleRate()) + " Hz"); |
291 } else if (!numberOfFrames) { | 291 } else if (!numberOfFrames) { |
292 exceptionState.throwDOMException( | 292 exceptionState.throwDOMException( |
293 NotSupportedError, | 293 NotSupportedError, |
294 "number of frames must be greater than 0."); | 294 "number of frames must be greater than 0."); |
295 } else { | 295 } else { |
296 exceptionState.throwDOMException( | 296 exceptionState.throwDOMException( |
297 NotSupportedError, | 297 NotSupportedError, |
298 "unable to create buffer of " + String::number(numberOfChannels) | 298 "unable to create buffer of " + String::number(numberOfChannels) |
299 + " channel(s) of " + String::number(numberOfFrames) | 299 + " channel(s) of " + String::number(numberOfFrames) |
300 + " frames each."); | 300 + " frames each."); |
301 } | 301 } |
302 return nullptr; | 302 return nullptr; |
303 } | 303 } |
304 | 304 |
305 return audioBuffer; | 305 return audioBuffer; |
haraken
2014/05/07 04:02:16
audioBuffer.release();
Not related to your CL, bu
keishi
2014/05/07 07:59:24
Done.
| |
306 } | 306 } |
307 | 307 |
308 void AudioContext::decodeAudioData(ArrayBuffer* audioData, PassOwnPtr<AudioBuffe rCallback> successCallback, PassOwnPtr<AudioBufferCallback> errorCallback, Excep tionState& exceptionState) | 308 void AudioContext::decodeAudioData(ArrayBuffer* audioData, PassOwnPtr<AudioBuffe rCallback> successCallback, PassOwnPtr<AudioBufferCallback> errorCallback, Excep tionState& exceptionState) |
309 { | 309 { |
310 if (!audioData) { | 310 if (!audioData) { |
311 exceptionState.throwDOMException( | 311 exceptionState.throwDOMException( |
312 SyntaxError, | 312 SyntaxError, |
313 "invalid ArrayBuffer for audioData."); | 313 "invalid ArrayBuffer for audioData."); |
314 return; | 314 return; |
315 } | 315 } |
316 m_audioDecoder.decodeAsync(audioData, sampleRate(), successCallback, errorCa llback); | 316 m_audioDecoder.decodeAsync(audioData, sampleRate(), successCallback, errorCa llback); |
317 } | 317 } |
318 | 318 |
319 PassRefPtr<AudioBufferSourceNode> AudioContext::createBufferSource() | 319 PassRefPtrWillBeRawPtr<AudioBufferSourceNode> AudioContext::createBufferSource() |
320 { | 320 { |
321 ASSERT(isMainThread()); | 321 ASSERT(isMainThread()); |
322 RefPtr<AudioBufferSourceNode> node = AudioBufferSourceNode::create(this, m_d estinationNode->sampleRate()); | 322 RefPtrWillBeRawPtr<AudioBufferSourceNode> node = AudioBufferSourceNode::crea te(this, m_destinationNode->sampleRate()); |
323 | 323 |
324 // Because this is an AudioScheduledSourceNode, the context keeps a referenc e until it has finished playing. | 324 // Because this is an AudioScheduledSourceNode, the context keeps a referenc e until it has finished playing. |
325 // When this happens, AudioScheduledSourceNode::finish() calls AudioContext: :notifyNodeFinishedProcessing(). | 325 // When this happens, AudioScheduledSourceNode::finish() calls AudioContext: :notifyNodeFinishedProcessing(). |
326 refNode(node.get()); | 326 refNode(node.get()); |
327 | 327 |
328 return node; | 328 return node; |
329 } | 329 } |
330 | 330 |
331 PassRefPtr<MediaElementAudioSourceNode> AudioContext::createMediaElementSource(H TMLMediaElement* mediaElement, ExceptionState& exceptionState) | 331 PassRefPtrWillBeRawPtr<MediaElementAudioSourceNode> AudioContext::createMediaEle mentSource(HTMLMediaElement* mediaElement, ExceptionState& exceptionState) |
332 { | 332 { |
333 ASSERT(isMainThread()); | 333 ASSERT(isMainThread()); |
334 if (!mediaElement) { | 334 if (!mediaElement) { |
335 exceptionState.throwDOMException( | 335 exceptionState.throwDOMException( |
336 InvalidStateError, | 336 InvalidStateError, |
337 "invalid HTMLMedialElement."); | 337 "invalid HTMLMedialElement."); |
338 return nullptr; | 338 return nullptr; |
339 } | 339 } |
340 | 340 |
341 // First check if this media element already has a source node. | 341 // First check if this media element already has a source node. |
342 if (mediaElement->audioSourceNode()) { | 342 if (mediaElement->audioSourceNode()) { |
343 exceptionState.throwDOMException( | 343 exceptionState.throwDOMException( |
344 InvalidStateError, | 344 InvalidStateError, |
345 "invalid HTMLMediaElement."); | 345 "invalid HTMLMediaElement."); |
346 return nullptr; | 346 return nullptr; |
347 } | 347 } |
348 | 348 |
349 RefPtr<MediaElementAudioSourceNode> node = MediaElementAudioSourceNode::crea te(this, mediaElement); | 349 RefPtrWillBeRawPtr<MediaElementAudioSourceNode> node = MediaElementAudioSour ceNode::create(this, mediaElement); |
350 | 350 |
351 mediaElement->setAudioSourceNode(node.get()); | 351 mediaElement->setAudioSourceNode(node.get()); |
352 | 352 |
353 refNode(node.get()); // context keeps reference until node is disconnected | 353 refNode(node.get()); // context keeps reference until node is disconnected |
354 return node; | 354 return node; |
355 } | 355 } |
356 | 356 |
357 PassRefPtr<MediaStreamAudioSourceNode> AudioContext::createMediaStreamSource(Med iaStream* mediaStream, ExceptionState& exceptionState) | 357 PassRefPtrWillBeRawPtr<MediaStreamAudioSourceNode> AudioContext::createMediaStre amSource(MediaStream* mediaStream, ExceptionState& exceptionState) |
358 { | 358 { |
359 ASSERT(isMainThread()); | 359 ASSERT(isMainThread()); |
360 if (!mediaStream) { | 360 if (!mediaStream) { |
361 exceptionState.throwDOMException( | 361 exceptionState.throwDOMException( |
362 InvalidStateError, | 362 InvalidStateError, |
363 "invalid MediaStream source"); | 363 "invalid MediaStream source"); |
364 return nullptr; | 364 return nullptr; |
365 } | 365 } |
366 | 366 |
367 MediaStreamTrackVector audioTracks = mediaStream->getAudioTracks(); | 367 MediaStreamTrackVector audioTracks = mediaStream->getAudioTracks(); |
368 if (audioTracks.isEmpty()) { | 368 if (audioTracks.isEmpty()) { |
369 exceptionState.throwDOMException( | 369 exceptionState.throwDOMException( |
370 InvalidStateError, | 370 InvalidStateError, |
371 "MediaStream has no audio track"); | 371 "MediaStream has no audio track"); |
372 return nullptr; | 372 return nullptr; |
373 } | 373 } |
374 | 374 |
375 // Use the first audio track in the media stream. | 375 // Use the first audio track in the media stream. |
376 RefPtr<MediaStreamTrack> audioTrack = audioTracks[0]; | 376 RefPtr<MediaStreamTrack> audioTrack = audioTracks[0]; |
377 OwnPtr<AudioSourceProvider> provider = audioTrack->createWebAudioSource(); | 377 OwnPtr<AudioSourceProvider> provider = audioTrack->createWebAudioSource(); |
378 RefPtr<MediaStreamAudioSourceNode> node = MediaStreamAudioSourceNode::create (this, mediaStream, audioTrack.get(), provider.release()); | 378 RefPtrWillBeRawPtr<MediaStreamAudioSourceNode> node = MediaStreamAudioSource Node::create(this, mediaStream, audioTrack.get(), provider.release()); |
379 | 379 |
380 // FIXME: Only stereo streams are supported right now. We should be able to accept multi-channel streams. | 380 // FIXME: Only stereo streams are supported right now. We should be able to accept multi-channel streams. |
381 node->setFormat(2, sampleRate()); | 381 node->setFormat(2, sampleRate()); |
382 | 382 |
383 refNode(node.get()); // context keeps reference until node is disconnected | 383 refNode(node.get()); // context keeps reference until node is disconnected |
384 return node; | 384 return node; |
385 } | 385 } |
386 | 386 |
387 PassRefPtr<MediaStreamAudioDestinationNode> AudioContext::createMediaStreamDesti nation() | 387 PassRefPtrWillBeRawPtr<MediaStreamAudioDestinationNode> AudioContext::createMedi aStreamDestination() |
388 { | 388 { |
389 // Set number of output channels to stereo by default. | 389 // Set number of output channels to stereo by default. |
390 return MediaStreamAudioDestinationNode::create(this, 2); | 390 return MediaStreamAudioDestinationNode::create(this, 2); |
391 } | 391 } |
392 | 392 |
393 PassRefPtr<ScriptProcessorNode> AudioContext::createScriptProcessor(ExceptionSta te& exceptionState) | 393 PassRefPtrWillBeRawPtr<ScriptProcessorNode> AudioContext::createScriptProcessor( ExceptionState& exceptionState) |
394 { | 394 { |
395 // Set number of input/output channels to stereo by default. | 395 // Set number of input/output channels to stereo by default. |
396 return createScriptProcessor(0, 2, 2, exceptionState); | 396 return createScriptProcessor(0, 2, 2, exceptionState); |
397 } | 397 } |
398 | 398 |
399 PassRefPtr<ScriptProcessorNode> AudioContext::createScriptProcessor(size_t buffe rSize, ExceptionState& exceptionState) | 399 PassRefPtrWillBeRawPtr<ScriptProcessorNode> AudioContext::createScriptProcessor( size_t bufferSize, ExceptionState& exceptionState) |
400 { | 400 { |
401 // Set number of input/output channels to stereo by default. | 401 // Set number of input/output channels to stereo by default. |
402 return createScriptProcessor(bufferSize, 2, 2, exceptionState); | 402 return createScriptProcessor(bufferSize, 2, 2, exceptionState); |
403 } | 403 } |
404 | 404 |
405 PassRefPtr<ScriptProcessorNode> AudioContext::createScriptProcessor(size_t buffe rSize, size_t numberOfInputChannels, ExceptionState& exceptionState) | 405 PassRefPtrWillBeRawPtr<ScriptProcessorNode> AudioContext::createScriptProcessor( size_t bufferSize, size_t numberOfInputChannels, ExceptionState& exceptionState) |
406 { | 406 { |
407 // Set number of output channels to stereo by default. | 407 // Set number of output channels to stereo by default. |
408 return createScriptProcessor(bufferSize, numberOfInputChannels, 2, exception State); | 408 return createScriptProcessor(bufferSize, numberOfInputChannels, 2, exception State); |
409 } | 409 } |
410 | 410 |
411 PassRefPtr<ScriptProcessorNode> AudioContext::createScriptProcessor(size_t buffe rSize, size_t numberOfInputChannels, size_t numberOfOutputChannels, ExceptionSta te& exceptionState) | 411 PassRefPtrWillBeRawPtr<ScriptProcessorNode> AudioContext::createScriptProcessor( size_t bufferSize, size_t numberOfInputChannels, size_t numberOfOutputChannels, ExceptionState& exceptionState) |
412 { | 412 { |
413 ASSERT(isMainThread()); | 413 ASSERT(isMainThread()); |
414 RefPtr<ScriptProcessorNode> node = ScriptProcessorNode::create(this, m_desti nationNode->sampleRate(), bufferSize, numberOfInputChannels, numberOfOutputChann els); | 414 RefPtrWillBeRawPtr<ScriptProcessorNode> node = ScriptProcessorNode::create(t his, m_destinationNode->sampleRate(), bufferSize, numberOfInputChannels, numberO fOutputChannels); |
415 | 415 |
416 if (!node.get()) { | 416 if (!node.get()) { |
417 if (!numberOfInputChannels && !numberOfOutputChannels) { | 417 if (!numberOfInputChannels && !numberOfOutputChannels) { |
418 exceptionState.throwDOMException( | 418 exceptionState.throwDOMException( |
419 IndexSizeError, | 419 IndexSizeError, |
420 "number of input channels and output channels cannot both be zer o."); | 420 "number of input channels and output channels cannot both be zer o."); |
421 } else if (numberOfInputChannels > AudioContext::maxNumberOfChannels()) { | 421 } else if (numberOfInputChannels > AudioContext::maxNumberOfChannels()) { |
422 exceptionState.throwDOMException( | 422 exceptionState.throwDOMException( |
423 IndexSizeError, | 423 IndexSizeError, |
424 "number of input channels (" + String::number(numberOfInputChann els) | 424 "number of input channels (" + String::number(numberOfInputChann els) |
(...skipping 11 matching lines...) Expand all Loading... | |
436 "buffer size (" + String::number(bufferSize) | 436 "buffer size (" + String::number(bufferSize) |
437 + ") must be a power of two between 256 and 16384."); | 437 + ") must be a power of two between 256 and 16384."); |
438 } | 438 } |
439 return nullptr; | 439 return nullptr; |
440 } | 440 } |
441 | 441 |
442 refNode(node.get()); // context keeps reference until we stop making javascr ipt rendering callbacks | 442 refNode(node.get()); // context keeps reference until we stop making javascr ipt rendering callbacks |
443 return node; | 443 return node; |
444 } | 444 } |
445 | 445 |
446 PassRefPtr<BiquadFilterNode> AudioContext::createBiquadFilter() | 446 PassRefPtrWillBeRawPtr<BiquadFilterNode> AudioContext::createBiquadFilter() |
447 { | 447 { |
448 ASSERT(isMainThread()); | 448 ASSERT(isMainThread()); |
449 return BiquadFilterNode::create(this, m_destinationNode->sampleRate()); | 449 return BiquadFilterNode::create(this, m_destinationNode->sampleRate()); |
450 } | 450 } |
451 | 451 |
452 PassRefPtr<WaveShaperNode> AudioContext::createWaveShaper() | 452 PassRefPtrWillBeRawPtr<WaveShaperNode> AudioContext::createWaveShaper() |
453 { | 453 { |
454 ASSERT(isMainThread()); | 454 ASSERT(isMainThread()); |
455 return WaveShaperNode::create(this); | 455 return WaveShaperNode::create(this); |
456 } | 456 } |
457 | 457 |
458 PassRefPtr<PannerNode> AudioContext::createPanner() | 458 PassRefPtrWillBeRawPtr<PannerNode> AudioContext::createPanner() |
459 { | 459 { |
460 ASSERT(isMainThread()); | 460 ASSERT(isMainThread()); |
461 return PannerNode::create(this, m_destinationNode->sampleRate()); | 461 return PannerNode::create(this, m_destinationNode->sampleRate()); |
462 } | 462 } |
463 | 463 |
464 PassRefPtr<ConvolverNode> AudioContext::createConvolver() | 464 PassRefPtrWillBeRawPtr<ConvolverNode> AudioContext::createConvolver() |
465 { | 465 { |
466 ASSERT(isMainThread()); | 466 ASSERT(isMainThread()); |
467 return ConvolverNode::create(this, m_destinationNode->sampleRate()); | 467 return ConvolverNode::create(this, m_destinationNode->sampleRate()); |
468 } | 468 } |
469 | 469 |
470 PassRefPtr<DynamicsCompressorNode> AudioContext::createDynamicsCompressor() | 470 PassRefPtrWillBeRawPtr<DynamicsCompressorNode> AudioContext::createDynamicsCompr essor() |
471 { | 471 { |
472 ASSERT(isMainThread()); | 472 ASSERT(isMainThread()); |
473 return DynamicsCompressorNode::create(this, m_destinationNode->sampleRate()) ; | 473 return DynamicsCompressorNode::create(this, m_destinationNode->sampleRate()) ; |
474 } | 474 } |
475 | 475 |
476 PassRefPtr<AnalyserNode> AudioContext::createAnalyser() | 476 PassRefPtrWillBeRawPtr<AnalyserNode> AudioContext::createAnalyser() |
477 { | 477 { |
478 ASSERT(isMainThread()); | 478 ASSERT(isMainThread()); |
479 return AnalyserNode::create(this, m_destinationNode->sampleRate()); | 479 return AnalyserNode::create(this, m_destinationNode->sampleRate()); |
480 } | 480 } |
481 | 481 |
482 PassRefPtr<GainNode> AudioContext::createGain() | 482 PassRefPtrWillBeRawPtr<GainNode> AudioContext::createGain() |
483 { | 483 { |
484 ASSERT(isMainThread()); | 484 ASSERT(isMainThread()); |
485 return GainNode::create(this, m_destinationNode->sampleRate()); | 485 return GainNode::create(this, m_destinationNode->sampleRate()); |
486 } | 486 } |
487 | 487 |
488 PassRefPtr<DelayNode> AudioContext::createDelay(ExceptionState& exceptionState) | 488 PassRefPtrWillBeRawPtr<DelayNode> AudioContext::createDelay(ExceptionState& exce ptionState) |
489 { | 489 { |
490 const double defaultMaxDelayTime = 1; | 490 const double defaultMaxDelayTime = 1; |
491 return createDelay(defaultMaxDelayTime, exceptionState); | 491 return createDelay(defaultMaxDelayTime, exceptionState); |
492 } | 492 } |
493 | 493 |
494 PassRefPtr<DelayNode> AudioContext::createDelay(double maxDelayTime, ExceptionSt ate& exceptionState) | 494 PassRefPtrWillBeRawPtr<DelayNode> AudioContext::createDelay(double maxDelayTime, ExceptionState& exceptionState) |
495 { | 495 { |
496 ASSERT(isMainThread()); | 496 ASSERT(isMainThread()); |
497 RefPtr<DelayNode> node = DelayNode::create(this, m_destinationNode->sampleRa te(), maxDelayTime, exceptionState); | 497 RefPtrWillBeRawPtr<DelayNode> node = DelayNode::create(this, m_destinationNo de->sampleRate(), maxDelayTime, exceptionState); |
498 if (exceptionState.hadException()) | 498 if (exceptionState.hadException()) |
499 return nullptr; | 499 return nullptr; |
500 return node; | 500 return node; |
501 } | 501 } |
502 | 502 |
503 PassRefPtr<ChannelSplitterNode> AudioContext::createChannelSplitter(ExceptionSta te& exceptionState) | 503 PassRefPtrWillBeRawPtr<ChannelSplitterNode> AudioContext::createChannelSplitter( ExceptionState& exceptionState) |
504 { | 504 { |
505 const unsigned ChannelSplitterDefaultNumberOfOutputs = 6; | 505 const unsigned ChannelSplitterDefaultNumberOfOutputs = 6; |
506 return createChannelSplitter(ChannelSplitterDefaultNumberOfOutputs, exceptio nState); | 506 return createChannelSplitter(ChannelSplitterDefaultNumberOfOutputs, exceptio nState); |
507 } | 507 } |
508 | 508 |
509 PassRefPtr<ChannelSplitterNode> AudioContext::createChannelSplitter(size_t numbe rOfOutputs, ExceptionState& exceptionState) | 509 PassRefPtrWillBeRawPtr<ChannelSplitterNode> AudioContext::createChannelSplitter( size_t numberOfOutputs, ExceptionState& exceptionState) |
510 { | 510 { |
511 ASSERT(isMainThread()); | 511 ASSERT(isMainThread()); |
512 RefPtr<ChannelSplitterNode> node = ChannelSplitterNode::create(this, m_desti nationNode->sampleRate(), numberOfOutputs); | 512 |
513 RefPtrWillBeRawPtr<ChannelSplitterNode> node = ChannelSplitterNode::create(t his, m_destinationNode->sampleRate(), numberOfOutputs); | |
513 | 514 |
514 if (!node.get()) { | 515 if (!node.get()) { |
515 exceptionState.throwDOMException( | 516 exceptionState.throwDOMException( |
516 IndexSizeError, | 517 IndexSizeError, |
517 "number of outputs (" + String::number(numberOfOutputs) | 518 "number of outputs (" + String::number(numberOfOutputs) |
518 + ") must be between 1 and " | 519 + ") must be between 1 and " |
519 + String::number(AudioContext::maxNumberOfChannels()) + "."); | 520 + String::number(AudioContext::maxNumberOfChannels()) + "."); |
520 return nullptr; | 521 return nullptr; |
521 } | 522 } |
522 | 523 |
523 return node; | 524 return node; |
524 } | 525 } |
525 | 526 |
526 PassRefPtr<ChannelMergerNode> AudioContext::createChannelMerger(ExceptionState& exceptionState) | 527 PassRefPtrWillBeRawPtr<ChannelMergerNode> AudioContext::createChannelMerger(Exce ptionState& exceptionState) |
527 { | 528 { |
528 const unsigned ChannelMergerDefaultNumberOfInputs = 6; | 529 const unsigned ChannelMergerDefaultNumberOfInputs = 6; |
529 return createChannelMerger(ChannelMergerDefaultNumberOfInputs, exceptionStat e); | 530 return createChannelMerger(ChannelMergerDefaultNumberOfInputs, exceptionStat e); |
530 } | 531 } |
531 | 532 |
532 PassRefPtr<ChannelMergerNode> AudioContext::createChannelMerger(size_t numberOfI nputs, ExceptionState& exceptionState) | 533 PassRefPtrWillBeRawPtr<ChannelMergerNode> AudioContext::createChannelMerger(size _t numberOfInputs, ExceptionState& exceptionState) |
533 { | 534 { |
534 ASSERT(isMainThread()); | 535 ASSERT(isMainThread()); |
535 RefPtr<ChannelMergerNode> node = ChannelMergerNode::create(this, m_destinati onNode->sampleRate(), numberOfInputs); | 536 |
537 RefPtrWillBeRawPtr<ChannelMergerNode> node = ChannelMergerNode::create(this, m_destinationNode->sampleRate(), numberOfInputs); | |
536 | 538 |
537 if (!node.get()) { | 539 if (!node.get()) { |
538 exceptionState.throwDOMException( | 540 exceptionState.throwDOMException( |
539 IndexSizeError, | 541 IndexSizeError, |
540 "number of inputs (" + String::number(numberOfInputs) | 542 "number of inputs (" + String::number(numberOfInputs) |
541 + ") must be between 1 and " | 543 + ") must be between 1 and " |
542 + String::number(AudioContext::maxNumberOfChannels()) + "."); | 544 + String::number(AudioContext::maxNumberOfChannels()) + "."); |
543 return nullptr; | 545 return nullptr; |
544 } | 546 } |
545 | 547 |
546 return node; | 548 return node; |
547 } | 549 } |
548 | 550 |
549 PassRefPtr<OscillatorNode> AudioContext::createOscillator() | 551 PassRefPtrWillBeRawPtr<OscillatorNode> AudioContext::createOscillator() |
550 { | 552 { |
551 ASSERT(isMainThread()); | 553 ASSERT(isMainThread()); |
552 RefPtr<OscillatorNode> node = OscillatorNode::create(this, m_destinationNode ->sampleRate()); | 554 |
555 RefPtrWillBeRawPtr<OscillatorNode> node = OscillatorNode::create(this, m_des tinationNode->sampleRate()); | |
553 | 556 |
554 // Because this is an AudioScheduledSourceNode, the context keeps a referenc e until it has finished playing. | 557 // Because this is an AudioScheduledSourceNode, the context keeps a referenc e until it has finished playing. |
555 // When this happens, AudioScheduledSourceNode::finish() calls AudioContext: :notifyNodeFinishedProcessing(). | 558 // When this happens, AudioScheduledSourceNode::finish() calls AudioContext: :notifyNodeFinishedProcessing(). |
556 refNode(node.get()); | 559 refNode(node.get()); |
557 | 560 |
558 return node; | 561 return node; |
559 } | 562 } |
560 | 563 |
561 PassRefPtr<PeriodicWave> AudioContext::createPeriodicWave(Float32Array* real, Fl oat32Array* imag, ExceptionState& exceptionState) | 564 PassRefPtrWillBeRawPtr<PeriodicWave> AudioContext::createPeriodicWave(Float32Arr ay* real, Float32Array* imag, ExceptionState& exceptionState) |
562 { | 565 { |
563 ASSERT(isMainThread()); | 566 ASSERT(isMainThread()); |
564 | 567 |
565 if (!real) { | 568 if (!real) { |
566 exceptionState.throwDOMException( | 569 exceptionState.throwDOMException( |
567 SyntaxError, | 570 SyntaxError, |
568 "invalid real array"); | 571 "invalid real array"); |
569 return nullptr; | 572 return nullptr; |
570 } | 573 } |
571 | 574 |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
833 | 836 |
834 context->deleteMarkedNodes(); | 837 context->deleteMarkedNodes(); |
835 context->deref(); | 838 context->deref(); |
836 } | 839 } |
837 | 840 |
838 void AudioContext::deleteMarkedNodes() | 841 void AudioContext::deleteMarkedNodes() |
839 { | 842 { |
840 ASSERT(isMainThread()); | 843 ASSERT(isMainThread()); |
841 | 844 |
842 // Protect this object from being deleted before we release the mutex locked by AutoLocker. | 845 // Protect this object from being deleted before we release the mutex locked by AutoLocker. |
843 RefPtr<AudioContext> protect(this); | 846 RefPtrWillBeRawPtr<AudioContext> protect(this); |
844 { | 847 { |
845 AutoLocker locker(this); | 848 AutoLocker locker(this); |
846 | 849 |
847 while (size_t n = m_nodesToDelete.size()) { | 850 while (size_t n = m_nodesToDelete.size()) { |
848 AudioNode* node = m_nodesToDelete[n - 1]; | 851 AudioNode* node = m_nodesToDelete[n - 1]; |
849 m_nodesToDelete.removeLast(); | 852 m_nodesToDelete.removeLast(); |
850 | 853 |
851 // Before deleting the node, clear out any AudioNodeInputs from m_di rtySummingJunctions. | 854 // Before deleting the node, clear out any AudioNodeInputs from m_di rtySummingJunctions. |
852 unsigned numberOfInputs = node->numberOfInputs(); | 855 unsigned numberOfInputs = node->numberOfInputs(); |
853 for (unsigned i = 0; i < numberOfInputs; ++i) | 856 for (unsigned i = 0; i < numberOfInputs; ++i) |
854 m_dirtySummingJunctions.remove(node->input(i)); | 857 m_dirtySummingJunctions.remove(node->input(i)); |
855 | 858 |
856 // Before deleting the node, clear out any AudioNodeOutputs from m_d irtyAudioNodeOutputs. | 859 // Before deleting the node, clear out any AudioNodeOutputs from m_d irtyAudioNodeOutputs. |
857 unsigned numberOfOutputs = node->numberOfOutputs(); | 860 unsigned numberOfOutputs = node->numberOfOutputs(); |
858 for (unsigned i = 0; i < numberOfOutputs; ++i) | 861 for (unsigned i = 0; i < numberOfOutputs; ++i) |
859 m_dirtyAudioNodeOutputs.remove(node->output(i)); | 862 m_dirtyAudioNodeOutputs.remove(node->output(i)); |
860 | 863 #if ENABLE(OILPAN) |
864 // Finally, clear the keep alive handle that keeps this | |
865 // object from being collected. | |
866 node->clearKeepAlive(); | |
867 #else | |
861 // Finally, delete it. | 868 // Finally, delete it. |
862 delete node; | 869 delete node; |
870 #endif | |
863 } | 871 } |
864 m_isDeletionScheduled = false; | 872 m_isDeletionScheduled = false; |
865 } | 873 } |
866 } | 874 } |
867 | 875 |
868 void AudioContext::markSummingJunctionDirty(AudioSummingJunction* summingJunctio n) | 876 void AudioContext::markSummingJunctionDirty(AudioSummingJunction* summingJunctio n) |
869 { | 877 { |
870 ASSERT(isGraphOwner()); | 878 ASSERT(isGraphOwner()); |
871 m_dirtySummingJunctions.add(summingJunction); | 879 m_dirtySummingJunctions.add(summingJunction); |
872 } | 880 } |
873 | 881 |
874 void AudioContext::removeMarkedSummingJunction(AudioSummingJunction* summingJunc tion) | 882 void AudioContext::removeMarkedSummingJunction(AudioSummingJunction* summingJunc tion) |
875 { | 883 { |
876 ASSERT(isMainThread()); | 884 ASSERT(isMainThread()); |
877 AutoLocker locker(this); | 885 AutoLocker locker(this); |
878 m_dirtySummingJunctions.remove(summingJunction); | 886 m_dirtySummingJunctions.remove(summingJunction); |
879 } | 887 } |
880 | 888 |
881 void AudioContext::markAudioNodeOutputDirty(AudioNodeOutput* output) | 889 void AudioContext::markAudioNodeOutputDirty(AudioNodeOutput* output) |
882 { | 890 { |
883 ASSERT(isGraphOwner()); | 891 ASSERT(isGraphOwner()); |
884 m_dirtyAudioNodeOutputs.add(output); | 892 m_dirtyAudioNodeOutputs.add(output); |
885 } | 893 } |
886 | 894 |
887 void AudioContext::handleDirtyAudioSummingJunctions() | 895 void AudioContext::handleDirtyAudioSummingJunctions() |
888 { | 896 { |
889 ASSERT(isGraphOwner()); | 897 ASSERT(isGraphOwner()); |
890 | 898 |
891 for (HashSet<AudioSummingJunction*>::iterator i = m_dirtySummingJunctions.be gin(); i != m_dirtySummingJunctions.end(); ++i) | 899 for (HashSet<AudioSummingJunction* >::iterator i = m_dirtySummingJunctions.b egin(); i != m_dirtySummingJunctions.end(); ++i) |
haraken
2014/05/07 04:02:16
mis-edit.
keishi
2014/05/07 07:59:24
Done.
| |
892 (*i)->updateRenderingState(); | 900 (*i)->updateRenderingState(); |
893 | 901 |
894 m_dirtySummingJunctions.clear(); | 902 m_dirtySummingJunctions.clear(); |
895 } | 903 } |
896 | 904 |
897 void AudioContext::handleDirtyAudioNodeOutputs() | 905 void AudioContext::handleDirtyAudioNodeOutputs() |
898 { | 906 { |
899 ASSERT(isGraphOwner()); | 907 ASSERT(isGraphOwner()); |
900 | 908 |
901 for (HashSet<AudioNodeOutput*>::iterator i = m_dirtyAudioNodeOutputs.begin() ; i != m_dirtyAudioNodeOutputs.end(); ++i) | 909 for (HashSet<AudioNodeOutput*>::iterator i = m_dirtyAudioNodeOutputs.begin() ; i != m_dirtyAudioNodeOutputs.end(); ++i) |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
977 if (!renderedBuffer) | 985 if (!renderedBuffer) |
978 return; | 986 return; |
979 | 987 |
980 // Avoid firing the event if the document has already gone away. | 988 // Avoid firing the event if the document has already gone away. |
981 if (executionContext()) { | 989 if (executionContext()) { |
982 // Call the offline rendering completion event listener. | 990 // Call the offline rendering completion event listener. |
983 dispatchEvent(OfflineAudioCompletionEvent::create(renderedBuffer)); | 991 dispatchEvent(OfflineAudioCompletionEvent::create(renderedBuffer)); |
984 } | 992 } |
985 } | 993 } |
986 | 994 |
995 void AudioContext::trace(Visitor* visitor) | |
996 { | |
997 visitor->trace(m_renderTarget); | |
998 visitor->trace(m_destinationNode); | |
999 visitor->trace(m_listener); | |
1000 visitor->trace(m_dirtySummingJunctions); | |
haraken
2014/05/07 04:02:16
m_dirtySummingJunctions should not be traced, sinc
keishi
2014/05/07 07:59:24
Done.
| |
1001 } | |
1002 | |
987 } // namespace WebCore | 1003 } // namespace WebCore |
988 | 1004 |
989 #endif // ENABLE(WEB_AUDIO) | 1005 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |