Bug 849713 - Part 3: Set the loop parameters on AudioBufferSourceNodeEngine if looping is turned on when start() gets called; r=roc

This commit is contained in:
Ehsan Akhgari 2013-03-10 14:11:12 -04:00
parent dca28d002b
commit 3ebb3793d6

View File

@ -194,6 +194,25 @@ AudioBufferSourceNode::Start(JSContext* aCx, double aWhen, double aOffset,
return;
}
// Don't compute and set the loop parameters unnecessarily
if (mLoop) {
double actualLoopStart, actualLoopEnd;
if (((mLoopStart != 0.0) || (mLoopEnd != 0.0)) &&
mLoopStart >= 0.0 && mLoopEnd > 0.0 &&
mLoopStart < mLoopEnd) {
actualLoopStart = (mLoopStart > length) ? 0.0 : mLoopStart;
actualLoopEnd = std::min(mLoopEnd, length);
} else {
actualLoopStart = 0.0;
actualLoopEnd = length;
}
int32_t loopStartTicks = NS_lround(actualLoopStart * rate);
int32_t loopEndTicks = NS_lround(actualLoopEnd * rate);
ns->SetInt32Parameter(AudioBufferSourceNodeEngine::LOOP, 1);
ns->SetInt32Parameter(AudioBufferSourceNodeEngine::LOOPSTART, loopStartTicks);
ns->SetInt32Parameter(AudioBufferSourceNodeEngine::LOOPEND, loopEndTicks);
}
ns->SetBuffer(data.forget());
// Don't set parameter unnecessarily
if (aWhen > 0.0) {