Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: Source/modules/webaudio/OscillatorNode.cpp

Issue 205173002: Move webaudio to oilpan (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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)
Mads Ager (chromium) 2014/03/20 08:33:28 We should get rid of this. We don't want to create
keishi 2014/03/27 07:39:37 Done.
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);
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 periodicWave = PeriodicWave::createSquare(sampleRate);
135 #endif
128 break; 136 break;
129 } 137 }
130 case SAWTOOTH: { 138 case SAWTOOTH: {
139 #if !ENABLE(OILPAN)
131 DEFINE_STATIC_REF(PeriodicWave, periodicWaveSawtooth, (PeriodicWave::cre ateSawtooth(sampleRate))); 140 DEFINE_STATIC_REF(PeriodicWave, periodicWaveSawtooth, (PeriodicWave::cre ateSawtooth(sampleRate)));
132 periodicWave = periodicWaveSawtooth; 141 periodicWave = periodicWaveSawtooth;
142 #else
143 periodicWave = PeriodicWave::createSawtooth(sampleRate);
144 #endif
133 break; 145 break;
134 } 146 }
135 case TRIANGLE: { 147 case TRIANGLE: {
148 #if !ENABLE(OILPAN)
136 DEFINE_STATIC_REF(PeriodicWave, periodicWaveTriangle, (PeriodicWave::cre ateTriangle(sampleRate))); 149 DEFINE_STATIC_REF(PeriodicWave, periodicWaveTriangle, (PeriodicWave::cre ateTriangle(sampleRate)));
137 periodicWave = periodicWaveTriangle; 150 periodicWave = periodicWaveTriangle;
151 #else
152 periodicWave = PeriodicWave::createTriangle(sampleRate);
153 #endif
138 break; 154 break;
139 } 155 }
140 case CUSTOM: 156 case CUSTOM:
141 default: 157 default:
142 // Return error for invalid types, including CUSTOM since setPeriodicWav e() method must be 158 // Return error for invalid types, including CUSTOM since setPeriodicWav e() method must be
143 // called explicitly. 159 // called explicitly.
144 return false; 160 return false;
145 } 161 }
146 162
147 setPeriodicWave(periodicWave); 163 setPeriodicWave(periodicWave);
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 MutexLocker processLocker(m_processLock); 352 MutexLocker processLocker(m_processLock);
337 m_periodicWave = periodicWave; 353 m_periodicWave = periodicWave;
338 m_type = CUSTOM; 354 m_type = CUSTOM;
339 } 355 }
340 356
341 bool OscillatorNode::propagatesSilence() const 357 bool OscillatorNode::propagatesSilence() const
342 { 358 {
343 return !isPlayingOrScheduled() || hasFinished() || !m_periodicWave.get(); 359 return !isPlayingOrScheduled() || hasFinished() || !m_periodicWave.get();
344 } 360 }
345 361
362 void OscillatorNode::trace(Visitor* visitor)
363 {
364 visitor->trace(m_frequency);
365 visitor->trace(m_detune);
366 visitor->trace(m_periodicWave);
367 AudioNode::trace(visitor);
368 }
369
346 } // namespace WebCore 370 } // namespace WebCore
347 371
348 #endif // ENABLE(WEB_AUDIO) 372 #endif // ENABLE(WEB_AUDIO)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698