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