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..d3bce65119d54918483dc1781269740473437fee 100644 |
| --- a/Source/modules/webaudio/AudioBufferSourceNode.cpp |
| +++ b/Source/modules/webaudio/AudioBufferSourceNode.cpp |
| @@ -381,13 +381,22 @@ 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); |
| + startPlaying(false, when, 0, buffer()->duration()); |
| } |
| -void AudioBufferSourceNode::startGrain(double when, double grainOffset, double grainDuration) |
| +void AudioBufferSourceNode::start(double when, double grainOffset) |
| +{ |
| + startPlaying(true, when, grainOffset, buffer()->duration()); |
| +} |
| + |
| +void AudioBufferSourceNode::start(double when, double grainOffset, double grainDuration) |
| +{ |
| + startPlaying(true, when, grainOffset, grainDuration); |
| +} |
| + |
| +void AudioBufferSourceNode::startPlaying(bool isGrain, double when, double grainOffset, double grainDuration) |
| { |
| ASSERT(isMainThread()); |
| @@ -397,23 +406,23 @@ void AudioBufferSourceNode::startGrain(double when, double grainOffset, double g |
| if (!buffer()) |
| return; |
| - // Do sanity checking of grain parameters versus buffer size. |
| - double bufferDuration = buffer()->duration(); |
| + if (isGrain) { |
|
Ken Russell (switch to Gerrit)
2013/10/28 23:06:31
It looks like an else clause is needed initializin
Raymond Toy (Google)
2013/10/28 23:20:38
m_grainOffset and m_grainDuration are initialized
Raymond Toy (Google)
2013/10/28 23:38:00
Done.
|
| + // Do sanity checking of grain parameters versus buffer size. |
| + double bufferDuration = buffer()->duration(); |
| - grainOffset = max(0.0, grainOffset); |
| - grainOffset = min(bufferDuration, grainOffset); |
| - m_grainOffset = grainOffset; |
| + grainOffset = max(0.0, grainOffset); |
| + grainOffset = min(bufferDuration, grainOffset); |
| + m_grainOffset = grainOffset; |
| - // Handle default/unspecified duration. |
| - double maxDuration = bufferDuration - grainOffset; |
| - if (!grainDuration) |
| - grainDuration = maxDuration; |
| + double maxDuration = bufferDuration - grainOffset; |
| - grainDuration = max(0.0, grainDuration); |
| - grainDuration = min(maxDuration, grainDuration); |
| - m_grainDuration = grainDuration; |
| + 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 = isGrain; |
|
Ken Russell (switch to Gerrit)
2013/10/28 23:06:31
I don't think this should be inside the conditiona
Raymond Toy (Google)
2013/10/28 23:38:00
Done.
|
| + } |
| m_startTime = when; |
| // We call timeToSampleFrame here since at playbackRate == 1 we don't want to go through linear interpolation |
| @@ -427,7 +436,10 @@ void AudioBufferSourceNode::startGrain(double when, double grainOffset, double g |
| void AudioBufferSourceNode::noteGrainOn(double when, double grainOffset, double grainDuration) |
| { |
| - startGrain(when, grainOffset, grainDuration); |
| + // Handle unspecified duration where 0 means the rest of the buffer. |
| + if (!grainDuration) |
| + grainDuration = buffer()->duration(); |
| + startPlaying(true, when, grainOffset, grainDuration); |
| } |
| double AudioBufferSourceNode::totalPitchRate() |