Chromium Code Reviews| Index: Source/modules/webaudio/AudioBufferSourceNode.cpp |
| diff --git a/Source/modules/webaudio/AudioBufferSourceNode.cpp b/Source/modules/webaudio/AudioBufferSourceNode.cpp |
| index e9bb788e033e897f967969f35a96ee6554fb5b2a..efc3344d5510ed70e9a063f5cb751a6372a322f2 100644 |
| --- a/Source/modules/webaudio/AudioBufferSourceNode.cpp |
| +++ b/Source/modules/webaudio/AudioBufferSourceNode.cpp |
| @@ -381,13 +381,17 @@ unsigned AudioBufferSourceNode::numberOfChannels() |
| return output(0)->numberOfChannels(); |
| } |
| -void AudioBufferSourceNode::startGrain(double when, double grainOffset) |
| +void AudioBufferSourceNode::start(double when) |
| { |
| - // Duration of 0 has special value, meaning calculate based on the entire buffer's duration. |
| - startGrain(when, grainOffset, 0); |
| + start(when, 0, buffer()->duration()); |
| } |
| -void AudioBufferSourceNode::startGrain(double when, double grainOffset, double grainDuration) |
| +void AudioBufferSourceNode::start(double when, double grainOffset) |
| +{ |
| + start(when, grainOffset, buffer()->duration() - grainOffset); |
| +} |
| + |
| +void AudioBufferSourceNode::start(double when, double grainOffset, double grainDuration) |
| { |
| ASSERT(isMainThread()); |
| @@ -404,16 +408,14 @@ void AudioBufferSourceNode::startGrain(double when, double grainOffset, double g |
| grainOffset = min(bufferDuration, grainOffset); |
| m_grainOffset = grainOffset; |
| - // Handle default/unspecified duration. |
| double maxDuration = bufferDuration - grainOffset; |
| - if (!grainDuration) |
| - grainDuration = maxDuration; |
| grainDuration = max(0.0, grainDuration); |
| grainDuration = min(maxDuration, grainDuration); |
| m_grainDuration = grainDuration; |
| - m_isGrain = true; |
| + // Make this a grain if we're not playing the entire buffer. |
| + m_isGrain = m_grainOffset || m_grainDuration != bufferDuration; |
|
Ken Russell (switch to Gerrit)
2013/10/28 21:32:30
The == comparison with bufferDuration seems like i
|
| m_startTime = when; |
| // We call timeToSampleFrame here since at playbackRate == 1 we don't want to go through linear interpolation |
| @@ -427,7 +429,7 @@ void AudioBufferSourceNode::startGrain(double when, double grainOffset, double g |
| void AudioBufferSourceNode::noteGrainOn(double when, double grainOffset, double grainDuration) |
| { |
| - startGrain(when, grainOffset, grainDuration); |
| + start(when, grainOffset, grainDuration); |
| } |
| double AudioBufferSourceNode::totalPitchRate() |