Fix VCMProcessTimer::TimeUntilProcess() unsigned-integer underflow problem.

BUG=1665
R=mflodman@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/1341004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3979 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
stefan@webrtc.org 2013-05-08 06:38:53 +00:00
parent b55a12ad32
commit d98e784f5f

View File

@ -33,9 +33,13 @@ VCMProcessTimer::Period() const
uint32_t
VCMProcessTimer::TimeUntilProcess() const
{
return static_cast<uint32_t>(
VCM_MAX(static_cast<int64_t>(_periodMs) -
(_clock->TimeInMilliseconds() - _latestMs), 0));
const int64_t time_since_process = _clock->TimeInMilliseconds() -
static_cast<int64_t>(_latestMs);
const int64_t time_until_process = static_cast<int64_t>(_periodMs) -
time_since_process;
if (time_until_process < 0)
return 0;
return time_until_process;
}
void