bug 1206362 be careful about double -> int conversion r=padenot

--HG--
extra : rebase_source : 66fd40ddd3794ac225c581bbae56445d92362e12
This commit is contained in:
Karl Tomlinson 2015-09-21 15:44:10 +12:00
Родитель d5c41b3131
Коммит 644913284f
1 изменённых файлов: 8 добавлений и 2 удалений

Просмотреть файл

@ -715,8 +715,14 @@ AudioBufferSourceNode::SendOffsetAndDurationParametersToStream(AudioNodeStream*
}
if (mDuration != std::numeric_limits<double>::min()) {
bufferEnd = std::min(bufferEnd,
offsetSamples + NS_lround(mDuration * rate));
MOZ_ASSERT(mDuration >= 0.0); // provided by Start()
MOZ_ASSERT(rate >= 0.0f); // provided by AudioBuffer::Create()
static_assert(std::numeric_limits<double>::digits >=
std::numeric_limits<decltype(bufferEnd)>::digits,
"bufferEnd should be represented exactly by double");
// + 0.5 rounds mDuration to nearest sample when assigned to bufferEnd.
bufferEnd = std::min<double>(bufferEnd,
offsetSamples + mDuration * rate + 0.5);
}
aStream->SetInt32Parameter(BUFFEREND, bufferEnd);