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

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

Issue 2159403002: Replace ASSERT with DCHECK in WebAudio (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 4 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
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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 } 129 }
130 130
131 setPeriodicWave(periodicWave); 131 setPeriodicWave(periodicWave);
132 m_type = type; 132 m_type = type;
133 return true; 133 return true;
134 } 134 }
135 135
136 bool OscillatorHandler::calculateSampleAccuratePhaseIncrements(size_t framesToPr ocess) 136 bool OscillatorHandler::calculateSampleAccuratePhaseIncrements(size_t framesToPr ocess)
137 { 137 {
138 bool isGood = framesToProcess <= m_phaseIncrements.size() && framesToProcess <= m_detuneValues.size(); 138 bool isGood = framesToProcess <= m_phaseIncrements.size() && framesToProcess <= m_detuneValues.size();
139 ASSERT(isGood); 139 DCHECK(isGood);
140 if (!isGood) 140 if (!isGood)
141 return false; 141 return false;
142 142
143 if (m_firstRender) { 143 if (m_firstRender) {
144 m_firstRender = false; 144 m_firstRender = false;
145 m_frequency->resetSmoothedValue(); 145 m_frequency->resetSmoothedValue();
146 m_detune->resetSmoothedValue(); 146 m_detune->resetSmoothedValue();
147 } 147 }
148 148
149 bool hasSampleAccurateValues = false; 149 bool hasSampleAccurateValues = false;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 201
202 void OscillatorHandler::process(size_t framesToProcess) 202 void OscillatorHandler::process(size_t framesToProcess)
203 { 203 {
204 AudioBus* outputBus = output(0).bus(); 204 AudioBus* outputBus = output(0).bus();
205 205
206 if (!isInitialized() || !outputBus->numberOfChannels()) { 206 if (!isInitialized() || !outputBus->numberOfChannels()) {
207 outputBus->zero(); 207 outputBus->zero();
208 return; 208 return;
209 } 209 }
210 210
211 ASSERT(framesToProcess <= m_phaseIncrements.size()); 211 DCHECK_LE(framesToProcess, m_phaseIncrements.size());
212 if (framesToProcess > m_phaseIncrements.size()) 212 if (framesToProcess > m_phaseIncrements.size())
213 return; 213 return;
214 214
215 // The audio thread can't block on this lock, so we call tryLock() instead. 215 // The audio thread can't block on this lock, so we call tryLock() instead.
216 MutexTryLocker tryLocker(m_processLock); 216 MutexTryLocker tryLocker(m_processLock);
217 if (!tryLocker.locked()) { 217 if (!tryLocker.locked()) {
218 // Too bad - the tryLock() failed. We must be in the middle of changing wave-tables. 218 // Too bad - the tryLock() failed. We must be in the middle of changing wave-tables.
219 outputBus->zero(); 219 outputBus->zero();
220 return; 220 return;
221 } 221 }
(...skipping 12 matching lines...) Expand all
234 if (!nonSilentFramesToProcess) { 234 if (!nonSilentFramesToProcess) {
235 outputBus->zero(); 235 outputBus->zero();
236 return; 236 return;
237 } 237 }
238 238
239 unsigned periodicWaveSize = m_periodicWave->periodicWaveSize(); 239 unsigned periodicWaveSize = m_periodicWave->periodicWaveSize();
240 double invPeriodicWaveSize = 1.0 / periodicWaveSize; 240 double invPeriodicWaveSize = 1.0 / periodicWaveSize;
241 241
242 float* destP = outputBus->channel(0)->mutableData(); 242 float* destP = outputBus->channel(0)->mutableData();
243 243
244 ASSERT(quantumFrameOffset <= framesToProcess); 244 DCHECK_LE(quantumFrameOffset, framesToProcess);
245 245
246 // We keep virtualReadIndex double-precision since we're accumulating values . 246 // We keep virtualReadIndex double-precision since we're accumulating values .
247 double virtualReadIndex = m_virtualReadIndex; 247 double virtualReadIndex = m_virtualReadIndex;
248 248
249 float rateScale = m_periodicWave->rateScale(); 249 float rateScale = m_periodicWave->rateScale();
250 float invRateScale = 1 / rateScale; 250 float invRateScale = 1 / rateScale;
251 bool hasSampleAccurateValues = calculateSampleAccuratePhaseIncrements(frames ToProcess); 251 bool hasSampleAccurateValues = calculateSampleAccuratePhaseIncrements(frames ToProcess);
252 252
253 float frequency = 0; 253 float frequency = 0;
254 float* higherWaveData = 0; 254 float* higherWaveData = 0;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 virtualReadIndex -= floor(virtualReadIndex * invPeriodicWaveSize) * peri odicWaveSize; 307 virtualReadIndex -= floor(virtualReadIndex * invPeriodicWaveSize) * peri odicWaveSize;
308 } 308 }
309 309
310 m_virtualReadIndex = virtualReadIndex; 310 m_virtualReadIndex = virtualReadIndex;
311 311
312 outputBus->clearSilentFlag(); 312 outputBus->clearSilentFlag();
313 } 313 }
314 314
315 void OscillatorHandler::setPeriodicWave(PeriodicWave* periodicWave) 315 void OscillatorHandler::setPeriodicWave(PeriodicWave* periodicWave)
316 { 316 {
317 ASSERT(isMainThread()); 317 DCHECK(isMainThread());
318 ASSERT(periodicWave); 318 DCHECK(periodicWave);
319 319
320 // This synchronizes with process(). 320 // This synchronizes with process().
321 MutexLocker processLocker(m_processLock); 321 MutexLocker processLocker(m_processLock);
322 m_periodicWave = periodicWave; 322 m_periodicWave = periodicWave;
323 m_type = CUSTOM; 323 m_type = CUSTOM;
324 } 324 }
325 325
326 bool OscillatorHandler::propagatesSilence() const 326 bool OscillatorHandler::propagatesSilence() const
327 { 327 {
328 return !isPlayingOrScheduled() || hasFinished() || !m_periodicWave.get(); 328 return !isPlayingOrScheduled() || hasFinished() || !m_periodicWave.get();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 return m_detune; 386 return m_detune;
387 } 387 }
388 388
389 void OscillatorNode::setPeriodicWave(PeriodicWave* wave) 389 void OscillatorNode::setPeriodicWave(PeriodicWave* wave)
390 { 390 {
391 oscillatorHandler().setPeriodicWave(wave); 391 oscillatorHandler().setPeriodicWave(wave);
392 } 392 }
393 393
394 } // namespace blink 394 } // namespace blink
395 395
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698