| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012, Google Inc. All rights reserved. | 2 * Copyright (C) 2012, 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 25 matching lines...) Expand all Loading... |
| 36 #include "wtf/MathExtras.h" | 36 #include "wtf/MathExtras.h" |
| 37 #include "wtf/StdLibExtras.h" | 37 #include "wtf/StdLibExtras.h" |
| 38 #include <algorithm> | 38 #include <algorithm> |
| 39 | 39 |
| 40 using namespace std; | 40 using namespace std; |
| 41 | 41 |
| 42 namespace WebCore { | 42 namespace WebCore { |
| 43 | 43 |
| 44 using namespace VectorMath; | 44 using namespace VectorMath; |
| 45 | 45 |
| 46 PassRefPtr<OscillatorNode> OscillatorNode::create(AudioContext* context, float s
ampleRate) | 46 PassRefPtrWillBeRawPtr<OscillatorNode> OscillatorNode::create(AudioContext* cont
ext, float sampleRate) |
| 47 { | 47 { |
| 48 return adoptRef(new OscillatorNode(context, sampleRate)); | 48 return adoptRefWillBeNoop(new OscillatorNode(context, sampleRate)); |
| 49 } | 49 } |
| 50 | 50 |
| 51 OscillatorNode::OscillatorNode(AudioContext* context, float sampleRate) | 51 OscillatorNode::OscillatorNode(AudioContext* context, float sampleRate) |
| 52 : AudioScheduledSourceNode(context, sampleRate) | 52 : AudioScheduledSourceNode(context, sampleRate) |
| 53 , m_type(SINE) | 53 , m_type(SINE) |
| 54 , m_firstRender(true) | 54 , m_firstRender(true) |
| 55 , m_virtualReadIndex(0) | 55 , m_virtualReadIndex(0) |
| 56 , m_phaseIncrements(AudioNode::ProcessingSizeInFrames) | 56 , m_phaseIncrements(AudioNode::ProcessingSizeInFrames) |
| 57 , m_detuneValues(AudioNode::ProcessingSizeInFrames) | 57 , m_detuneValues(AudioNode::ProcessingSizeInFrames) |
| 58 { | 58 { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 ASSERT_NOT_REACHED(); | 111 ASSERT_NOT_REACHED(); |
| 112 } | 112 } |
| 113 | 113 |
| 114 bool OscillatorNode::setType(unsigned type) | 114 bool OscillatorNode::setType(unsigned type) |
| 115 { | 115 { |
| 116 PeriodicWave* periodicWave = 0; | 116 PeriodicWave* periodicWave = 0; |
| 117 float sampleRate = this->sampleRate(); | 117 float sampleRate = this->sampleRate(); |
| 118 | 118 |
| 119 switch (type) { | 119 switch (type) { |
| 120 case SINE: { | 120 case SINE: { |
| 121 DEFINE_STATIC_REF(PeriodicWave, periodicWaveSine, (PeriodicWave::createS
ine(sampleRate))); | 121 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(PeriodicWave, periodicWaveSine, (Pe
riodicWave::createSine(sampleRate))); |
| 122 periodicWave = periodicWaveSine; | 122 periodicWave = periodicWaveSine; |
| 123 break; | 123 break; |
| 124 } | 124 } |
| 125 case SQUARE: { | 125 case SQUARE: { |
| 126 DEFINE_STATIC_REF(PeriodicWave, periodicWaveSquare, (PeriodicWave::creat
eSquare(sampleRate))); | 126 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(PeriodicWave, periodicWaveSquare, (
PeriodicWave::createSquare(sampleRate))); |
| 127 periodicWave = periodicWaveSquare; | 127 periodicWave = periodicWaveSquare; |
| 128 break; | 128 break; |
| 129 } | 129 } |
| 130 case SAWTOOTH: { | 130 case SAWTOOTH: { |
| 131 DEFINE_STATIC_REF(PeriodicWave, periodicWaveSawtooth, (PeriodicWave::cre
ateSawtooth(sampleRate))); | 131 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(PeriodicWave, periodicWaveSawtooth,
(PeriodicWave::createSawtooth(sampleRate))); |
| 132 periodicWave = periodicWaveSawtooth; | 132 periodicWave = periodicWaveSawtooth; |
| 133 break; | 133 break; |
| 134 } | 134 } |
| 135 case TRIANGLE: { | 135 case TRIANGLE: { |
| 136 DEFINE_STATIC_REF(PeriodicWave, periodicWaveTriangle, (PeriodicWave::cre
ateTriangle(sampleRate))); | 136 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(PeriodicWave, periodicWaveTriangle,
(PeriodicWave::createTriangle(sampleRate))); |
| 137 periodicWave = periodicWaveTriangle; | 137 periodicWave = periodicWaveTriangle; |
| 138 break; | 138 break; |
| 139 } | 139 } |
| 140 case CUSTOM: | 140 case CUSTOM: |
| 141 default: | 141 default: |
| 142 // Return error for invalid types, including CUSTOM since setPeriodicWav
e() method must be | 142 // Return error for invalid types, including CUSTOM since setPeriodicWav
e() method must be |
| 143 // called explicitly. | 143 // called explicitly. |
| 144 return false; | 144 return false; |
| 145 } | 145 } |
| 146 | 146 |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 MutexLocker processLocker(m_processLock); | 336 MutexLocker processLocker(m_processLock); |
| 337 m_periodicWave = periodicWave; | 337 m_periodicWave = periodicWave; |
| 338 m_type = CUSTOM; | 338 m_type = CUSTOM; |
| 339 } | 339 } |
| 340 | 340 |
| 341 bool OscillatorNode::propagatesSilence() const | 341 bool OscillatorNode::propagatesSilence() const |
| 342 { | 342 { |
| 343 return !isPlayingOrScheduled() || hasFinished() || !m_periodicWave.get(); | 343 return !isPlayingOrScheduled() || hasFinished() || !m_periodicWave.get(); |
| 344 } | 344 } |
| 345 | 345 |
| 346 void OscillatorNode::trace(Visitor* visitor) |
| 347 { |
| 348 visitor->trace(m_frequency); |
| 349 visitor->trace(m_detune); |
| 350 visitor->trace(m_periodicWave); |
| 351 AudioScheduledSourceNode::trace(visitor); |
| 352 } |
| 353 |
| 346 } // namespace WebCore | 354 } // namespace WebCore |
| 347 | 355 |
| 348 #endif // ENABLE(WEB_AUDIO) | 356 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |