Chromium Code Reviews| 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 #if !ENABLE(OILPAN) | |
| 121 DEFINE_STATIC_REF(PeriodicWave, periodicWaveSine, (PeriodicWave::createS ine(sampleRate))); | 122 DEFINE_STATIC_REF(PeriodicWave, periodicWaveSine, (PeriodicWave::createS ine(sampleRate))); |
| 122 periodicWave = periodicWaveSine; | 123 periodicWave = periodicWaveSine; |
| 124 #else | |
| 125 periodicWave = PeriodicWave::createSine(sampleRate); | |
|
haraken
2014/03/27 11:44:05
You need to store the created pointer into a stati
keishi
2014/04/03 06:53:19
Done. Created DEFINE_STATIC_REF_WILL_BE_PERSISTENT
| |
| 126 #endif | |
| 123 break; | 127 break; |
| 124 } | 128 } |
| 125 case SQUARE: { | 129 case SQUARE: { |
| 130 #if !ENABLE(OILPAN) | |
| 126 DEFINE_STATIC_REF(PeriodicWave, periodicWaveSquare, (PeriodicWave::creat eSquare(sampleRate))); | 131 DEFINE_STATIC_REF(PeriodicWave, periodicWaveSquare, (PeriodicWave::creat eSquare(sampleRate))); |
| 127 periodicWave = periodicWaveSquare; | 132 periodicWave = periodicWaveSquare; |
| 133 #else | |
| 134 Persistent<PeriodicWave> periodicWaveSquare = PeriodicWave::createSquare (sampleRate); | |
|
haraken
2014/03/27 11:44:05
Use DEFINE_STATIC_LOCAL.
keishi
2014/04/03 06:53:19
Done.
| |
| 135 periodicWave = periodicWaveSquare; | |
| 136 #endif | |
| 128 break; | 137 break; |
| 129 } | 138 } |
| 130 case SAWTOOTH: { | 139 case SAWTOOTH: { |
| 140 #if !ENABLE(OILPAN) | |
| 131 DEFINE_STATIC_REF(PeriodicWave, periodicWaveSawtooth, (PeriodicWave::cre ateSawtooth(sampleRate))); | 141 DEFINE_STATIC_REF(PeriodicWave, periodicWaveSawtooth, (PeriodicWave::cre ateSawtooth(sampleRate))); |
| 132 periodicWave = periodicWaveSawtooth; | 142 periodicWave = periodicWaveSawtooth; |
| 143 #else | |
| 144 Persistent<PeriodicWave> periodicWaveSawtooth = PeriodicWave::createSawt ooth(sampleRate); | |
|
haraken
2014/03/27 11:44:05
Ditto.
keishi
2014/04/03 06:53:19
Done.
| |
| 145 periodicWave = periodicWaveSawtooth; | |
| 146 #endif | |
| 133 break; | 147 break; |
| 134 } | 148 } |
| 135 case TRIANGLE: { | 149 case TRIANGLE: { |
| 150 #if !ENABLE(OILPAN) | |
| 136 DEFINE_STATIC_REF(PeriodicWave, periodicWaveTriangle, (PeriodicWave::cre ateTriangle(sampleRate))); | 151 DEFINE_STATIC_REF(PeriodicWave, periodicWaveTriangle, (PeriodicWave::cre ateTriangle(sampleRate))); |
| 137 periodicWave = periodicWaveTriangle; | 152 periodicWave = periodicWaveTriangle; |
| 153 #else | |
| 154 Persistent<PeriodicWave> periodicWaveTriangle = PeriodicWave::createTria ngle(sampleRate); | |
|
haraken
2014/03/27 11:44:05
Ditto.
Probably it might be worth introducing DEF
keishi
2014/04/03 06:53:19
Done.
| |
| 155 periodicWave = periodicWaveTriangle; | |
| 156 #endif | |
| 138 break; | 157 break; |
| 139 } | 158 } |
| 140 case CUSTOM: | 159 case CUSTOM: |
| 141 default: | 160 default: |
| 142 // Return error for invalid types, including CUSTOM since setPeriodicWav e() method must be | 161 // Return error for invalid types, including CUSTOM since setPeriodicWav e() method must be |
| 143 // called explicitly. | 162 // called explicitly. |
| 144 return false; | 163 return false; |
| 145 } | 164 } |
| 146 | 165 |
| 147 setPeriodicWave(periodicWave); | 166 setPeriodicWave(periodicWave); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 336 MutexLocker processLocker(m_processLock); | 355 MutexLocker processLocker(m_processLock); |
| 337 m_periodicWave = periodicWave; | 356 m_periodicWave = periodicWave; |
| 338 m_type = CUSTOM; | 357 m_type = CUSTOM; |
| 339 } | 358 } |
| 340 | 359 |
| 341 bool OscillatorNode::propagatesSilence() const | 360 bool OscillatorNode::propagatesSilence() const |
| 342 { | 361 { |
| 343 return !isPlayingOrScheduled() || hasFinished() || !m_periodicWave.get(); | 362 return !isPlayingOrScheduled() || hasFinished() || !m_periodicWave.get(); |
| 344 } | 363 } |
| 345 | 364 |
| 365 void OscillatorNode::trace(Visitor* visitor) | |
| 366 { | |
| 367 visitor->trace(m_frequency); | |
| 368 visitor->trace(m_detune); | |
| 369 visitor->trace(m_periodicWave); | |
| 370 AudioNode::trace(visitor); | |
|
Mads Ager (chromium)
2014/03/27 11:06:49
We should call the immediate super class trace her
keishi
2014/04/03 06:53:19
Done.
| |
| 371 } | |
| 372 | |
| 346 } // namespace WebCore | 373 } // namespace WebCore |
| 347 | 374 |
| 348 #endif // ENABLE(WEB_AUDIO) | 375 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |