| 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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 } | 232 } |
| 233 | 233 |
| 234 // We must access m_periodicWave only inside the lock. | 234 // We must access m_periodicWave only inside the lock. |
| 235 if (!m_periodicWave.get()) { | 235 if (!m_periodicWave.get()) { |
| 236 outputBus->zero(); | 236 outputBus->zero(); |
| 237 return; | 237 return; |
| 238 } | 238 } |
| 239 | 239 |
| 240 size_t quantumFrameOffset; | 240 size_t quantumFrameOffset; |
| 241 size_t nonSilentFramesToProcess; | 241 size_t nonSilentFramesToProcess; |
| 242 double startFrameOffset; | |
| 243 | 242 |
| 244 updateSchedulingInfo(framesToProcess, outputBus, quantumFrameOffset, | 243 updateSchedulingInfo(framesToProcess, outputBus, quantumFrameOffset, |
| 245 nonSilentFramesToProcess, startFrameOffset); | 244 nonSilentFramesToProcess); |
| 246 | 245 |
| 247 if (!nonSilentFramesToProcess) { | 246 if (!nonSilentFramesToProcess) { |
| 248 outputBus->zero(); | 247 outputBus->zero(); |
| 249 return; | 248 return; |
| 250 } | 249 } |
| 251 | 250 |
| 252 unsigned periodicWaveSize = m_periodicWave->periodicWaveSize(); | 251 unsigned periodicWaveSize = m_periodicWave->periodicWaveSize(); |
| 253 double invPeriodicWaveSize = 1.0 / periodicWaveSize; | 252 double invPeriodicWaveSize = 1.0 / periodicWaveSize; |
| 254 | 253 |
| 255 float* destP = outputBus->channel(0)->mutableData(); | 254 float* destP = outputBus->channel(0)->mutableData(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 280 | 279 |
| 281 float incr = frequency * rateScale; | 280 float incr = frequency * rateScale; |
| 282 float* phaseIncrements = m_phaseIncrements.data(); | 281 float* phaseIncrements = m_phaseIncrements.data(); |
| 283 | 282 |
| 284 unsigned readIndexMask = periodicWaveSize - 1; | 283 unsigned readIndexMask = periodicWaveSize - 1; |
| 285 | 284 |
| 286 // Start rendering at the correct offset. | 285 // Start rendering at the correct offset. |
| 287 destP += quantumFrameOffset; | 286 destP += quantumFrameOffset; |
| 288 int n = nonSilentFramesToProcess; | 287 int n = nonSilentFramesToProcess; |
| 289 | 288 |
| 290 // If startFrameOffset is not 0, that means the oscillator doesn't actually | |
| 291 // start at quantumFrameOffset, but just past that time. Adjust destP and n | |
| 292 // to reflect that, and adjust virtualReadIndex to start the value at | |
| 293 // startFrameOffset. | |
| 294 if (startFrameOffset > 0) { | |
| 295 ++destP; | |
| 296 --n; | |
| 297 virtualReadIndex += (1 - startFrameOffset) * frequency * rateScale; | |
| 298 DCHECK(virtualReadIndex < periodicWaveSize); | |
| 299 } else if (startFrameOffset < 0) { | |
| 300 virtualReadIndex = -startFrameOffset * frequency * rateScale; | |
| 301 } | |
| 302 | |
| 303 while (n--) { | 289 while (n--) { |
| 304 unsigned readIndex = static_cast<unsigned>(virtualReadIndex); | 290 unsigned readIndex = static_cast<unsigned>(virtualReadIndex); |
| 305 unsigned readIndex2 = readIndex + 1; | 291 unsigned readIndex2 = readIndex + 1; |
| 306 | 292 |
| 307 // Contain within valid range. | 293 // Contain within valid range. |
| 308 readIndex = readIndex & readIndexMask; | 294 readIndex = readIndex & readIndexMask; |
| 309 readIndex2 = readIndex2 & readIndexMask; | 295 readIndex2 = readIndex2 & readIndexMask; |
| 310 | 296 |
| 311 if (hasSampleAccurateValues) { | 297 if (hasSampleAccurateValues) { |
| 312 incr = *phaseIncrements++; | 298 incr = *phaseIncrements++; |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 | 444 |
| 459 AudioParam* OscillatorNode::detune() { | 445 AudioParam* OscillatorNode::detune() { |
| 460 return m_detune; | 446 return m_detune; |
| 461 } | 447 } |
| 462 | 448 |
| 463 void OscillatorNode::setPeriodicWave(PeriodicWave* wave) { | 449 void OscillatorNode::setPeriodicWave(PeriodicWave* wave) { |
| 464 oscillatorHandler().setPeriodicWave(wave); | 450 oscillatorHandler().setPeriodicWave(wave); |
| 465 } | 451 } |
| 466 | 452 |
| 467 } // namespace blink | 453 } // namespace blink |
| OLD | NEW |