Chromium Code Reviews| Index: media/cast/cast_defines.h |
| diff --git a/media/cast/cast_defines.h b/media/cast/cast_defines.h |
| index b0f9370186e9e60e2cd0a7dc0f8032d603ea4e4a..94f0ef82f10d78199ae49d87c1e95d22db5099eb 100644 |
| --- a/media/cast/cast_defines.h |
| +++ b/media/cast/cast_defines.h |
| @@ -7,6 +7,7 @@ |
| #include <stdint.h> |
| +#include <limits> |
| #include <map> |
| #include <set> |
| @@ -135,13 +136,17 @@ inline base::TimeDelta ConvertFromNtpDiff(uint32 ntp_delay) { |
| return base::TimeDelta::FromMilliseconds(delay_ms); |
| } |
| -inline void ConvertTimeToFractions(int64 time_us, |
| +inline void ConvertTimeToFractions(int64 ntp_time_us, |
| uint32* seconds, |
| uint32* fractions) { |
| - DCHECK_GE(time_us, 0) << "Time must NOT be negative"; |
| - *seconds = static_cast<uint32>(time_us / base::Time::kMicrosecondsPerSecond); |
| + DCHECK_GE(ntp_time_us, 0) << "Time must NOT be negative"; |
| + const int64 seconds_component = |
| + ntp_time_us / base::Time::kMicrosecondsPerSecond; |
| + CHECK(seconds_component <= std::numeric_limits<uint32>::max()); |
|
hubbe
2014/05/14 23:12:23
When will this wrap?
What happens when if wraps?
miu
2014/05/16 22:45:47
Done. Documented.
|
| + *seconds = static_cast<uint32>(seconds_component); |
| *fractions = static_cast<uint32>( |
| - (time_us % base::Time::kMicrosecondsPerSecond) * kMagicFractionalUnit); |
| + (ntp_time_us % base::Time::kMicrosecondsPerSecond) * |
| + kMagicFractionalUnit); |
| } |
| inline void ConvertTimeTicksToNtp(const base::TimeTicks& time, |