| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 AudioBufferSourceNode::AudioBufferSourceNode(AudioContext* context, float sample
Rate) | 57 AudioBufferSourceNode::AudioBufferSourceNode(AudioContext* context, float sample
Rate) |
| 58 : AudioScheduledSourceNode(context, sampleRate) | 58 : AudioScheduledSourceNode(context, sampleRate) |
| 59 , m_buffer(nullptr) | 59 , m_buffer(nullptr) |
| 60 , m_isLooping(false) | 60 , m_isLooping(false) |
| 61 , m_loopStart(0) | 61 , m_loopStart(0) |
| 62 , m_loopEnd(0) | 62 , m_loopEnd(0) |
| 63 , m_virtualReadIndex(0) | 63 , m_virtualReadIndex(0) |
| 64 , m_isGrain(false) | 64 , m_isGrain(false) |
| 65 , m_grainOffset(0.0) | 65 , m_grainOffset(0.0) |
| 66 , m_grainDuration(DefaultGrainDuration) | 66 , m_grainDuration(DefaultGrainDuration) |
| 67 , m_pannerNode(0) | |
| 68 { | 67 { |
| 69 ScriptWrappable::init(this); | 68 ScriptWrappable::init(this); |
| 70 setNodeType(NodeTypeAudioBufferSource); | 69 setNodeType(NodeTypeAudioBufferSource); |
| 71 | 70 |
| 72 m_playbackRate = AudioParam::create(context, "playbackRate", 1.0, 0.0, MaxRa
te); | 71 m_playbackRate = AudioParam::create(context, "playbackRate", 1.0, 0.0, MaxRa
te); |
| 73 | 72 |
| 74 // Default to mono. A call to setBuffer() will set the number of output | 73 // Default to mono. A call to setBuffer() will set the number of output |
| 75 // channels to that of the buffer. | 74 // channels to that of the buffer. |
| 76 addOutput(AudioNodeOutput::create(this, 1)); | 75 addOutput(AudioNodeOutput::create(this, 1)); |
| 77 | 76 |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 } | 444 } |
| 446 | 445 |
| 447 bool AudioBufferSourceNode::propagatesSilence() const | 446 bool AudioBufferSourceNode::propagatesSilence() const |
| 448 { | 447 { |
| 449 return !isPlayingOrScheduled() || hasFinished() || !m_buffer; | 448 return !isPlayingOrScheduled() || hasFinished() || !m_buffer; |
| 450 } | 449 } |
| 451 | 450 |
| 452 void AudioBufferSourceNode::setPannerNode(PannerNode* pannerNode) | 451 void AudioBufferSourceNode::setPannerNode(PannerNode* pannerNode) |
| 453 { | 452 { |
| 454 if (m_pannerNode != pannerNode && !hasFinished()) { | 453 if (m_pannerNode != pannerNode && !hasFinished()) { |
| 454 RefPtr<PannerNode> oldPannerNode(m_pannerNode.release()); |
| 455 m_pannerNode = pannerNode; |
| 455 if (pannerNode) | 456 if (pannerNode) |
| 456 pannerNode->ref(AudioNode::RefTypeConnection); | 457 pannerNode->wasConnected(); |
| 457 if (m_pannerNode) | 458 if (oldPannerNode) |
| 458 m_pannerNode->deref(AudioNode::RefTypeConnection); | 459 oldPannerNode->willBeDisconnected(); |
| 459 | |
| 460 m_pannerNode = pannerNode; | |
| 461 } | 460 } |
| 462 } | 461 } |
| 463 | 462 |
| 464 void AudioBufferSourceNode::clearPannerNode() | 463 void AudioBufferSourceNode::clearPannerNode() |
| 465 { | 464 { |
| 466 if (m_pannerNode) { | 465 if (m_pannerNode) { |
| 467 m_pannerNode->deref(AudioNode::RefTypeConnection); | 466 m_pannerNode->willBeDisconnected(); |
| 468 m_pannerNode = 0; | 467 m_pannerNode.clear(); |
| 469 } | 468 } |
| 470 } | 469 } |
| 471 | 470 |
| 472 void AudioBufferSourceNode::finish() | 471 void AudioBufferSourceNode::finish() |
| 473 { | 472 { |
| 474 clearPannerNode(); | 473 clearPannerNode(); |
| 475 ASSERT(!m_pannerNode); | 474 ASSERT(!m_pannerNode); |
| 476 AudioScheduledSourceNode::finish(); | 475 AudioScheduledSourceNode::finish(); |
| 477 } | 476 } |
| 478 | 477 |
| 479 void AudioBufferSourceNode::trace(Visitor* visitor) | 478 void AudioBufferSourceNode::trace(Visitor* visitor) |
| 480 { | 479 { |
| 481 visitor->trace(m_buffer); | 480 visitor->trace(m_buffer); |
| 482 visitor->trace(m_playbackRate); | 481 visitor->trace(m_playbackRate); |
| 483 AudioScheduledSourceNode::trace(visitor); | 482 AudioScheduledSourceNode::trace(visitor); |
| 484 } | 483 } |
| 485 | 484 |
| 486 } // namespace WebCore | 485 } // namespace WebCore |
| 487 | 486 |
| 488 #endif // ENABLE(WEB_AUDIO) | 487 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |