Index: third_party/WebKit/Source/modules/webaudio/OscillatorNode.cpp |
diff --git a/third_party/WebKit/Source/modules/webaudio/OscillatorNode.cpp b/third_party/WebKit/Source/modules/webaudio/OscillatorNode.cpp |
index ca484863958c8b70f9ba754a57702524fb52278e..25d724381734dea9e73c497c88add39840681ec2 100644 |
--- a/third_party/WebKit/Source/modules/webaudio/OscillatorNode.cpp |
+++ b/third_party/WebKit/Source/modules/webaudio/OscillatorNode.cpp |
@@ -239,9 +239,10 @@ void OscillatorHandler::process(size_t framesToProcess) { |
size_t quantumFrameOffset; |
size_t nonSilentFramesToProcess; |
+ double startFrameOffset; |
updateSchedulingInfo(framesToProcess, outputBus, quantumFrameOffset, |
- nonSilentFramesToProcess); |
+ nonSilentFramesToProcess, startFrameOffset); |
if (!nonSilentFramesToProcess) { |
outputBus->zero(); |
@@ -286,6 +287,19 @@ void OscillatorHandler::process(size_t framesToProcess) { |
destP += quantumFrameOffset; |
int n = nonSilentFramesToProcess; |
+ // If startFrameOffset is not 0, that means the oscillator doesn't actually |
+ // start at quantumFrameOffset, but just past that time. Adjust destP and n |
+ // to reflect that, and adjust virtualReadIndex to start the value at |
+ // startFrameOffset. |
+ if (startFrameOffset > 0) { |
+ ++destP; |
+ --n; |
+ virtualReadIndex += (1 - startFrameOffset) * frequency * rateScale; |
+ DCHECK(virtualReadIndex < periodicWaveSize); |
+ } else if (startFrameOffset < 0) { |
+ virtualReadIndex = -startFrameOffset * frequency * rateScale; |
+ } |
+ |
while (n--) { |
unsigned readIndex = static_cast<unsigned>(virtualReadIndex); |
unsigned readIndex2 = readIndex + 1; |