diff --git a/rtc_base/system_time.cc b/rtc_base/system_time.cc index ea9b5ab330..bcd4e6c628 100644 --- a/rtc_base/system_time.cc +++ b/rtc_base/system_time.cc @@ -63,7 +63,7 @@ int64_t SystemTimeNanos() { ticks = kNumNanosecsPerSec * static_cast(ts.tv_sec) + static_cast(ts.tv_nsec); #elif defined(WINUWP) - ticks = TimeHelper::TicksNs(); + ticks = WinUwpSystemTimeNanos(); #elif defined(WEBRTC_WIN) static volatile LONG last_timegettime = 0; static volatile int64_t num_wrap_timegettime = 0; diff --git a/rtc_base/time_utils.cc b/rtc_base/time_utils.cc index f54aef420b..fe63d3a8ed 100644 --- a/rtc_base/time_utils.cc +++ b/rtc_base/time_utils.cc @@ -133,6 +133,10 @@ void SyncWithNtp(int64_t time_from_ntp_server_ms) { TimeHelper::SyncWithNtp(time_from_ntp_server_ms); } +int64_t WinUwpSystemTimeNanos() { + return TimeHelper::TicksNs(); +} + #endif // defined(WINUWP) int64_t SystemTimeMillis() { diff --git a/rtc_base/time_utils.h b/rtc_base/time_utils.h index ff22a6149a..de3c58c815 100644 --- a/rtc_base/time_utils.h +++ b/rtc_base/time_utils.h @@ -62,6 +62,12 @@ RTC_EXPORT ClockInterface* GetClockForTesting(); // Synchronizes the current clock based upon an NTP server's epoch in // milliseconds. void SyncWithNtp(int64_t time_from_ntp_server_ms); + +// Returns the current time in nanoseconds. The clock is synchonized with the +// system wall clock time upon instatiation. It may also be synchronized using +// the SyncWithNtp() function above. Please note that the clock will most likely +// drift away from the system wall clock time as time goes by. +int64_t WinUwpSystemTimeNanos(); #endif // defined(WINUWP) // Returns the actual system time, even if a clock is set for testing. diff --git a/system_wrappers/source/clock.cc b/system_wrappers/source/clock.cc index 0ae624d849..8edffa6a05 100644 --- a/system_wrappers/source/clock.cc +++ b/system_wrappers/source/clock.cc @@ -90,10 +90,10 @@ class WinUwpRealTimeClock final : public RealTimeClock { protected: timeval CurrentTimeVal() override { - // The rtc::SystemTimeNanos() method is already time offset from a base - // epoch value and might as be synchronized against an NTP time server as - // an added bonus. - auto nanos = rtc::SystemTimeNanos(); + // The rtc::WinUwpSystemTimeNanos() method is already time offset from a + // base epoch value and might as be synchronized against an NTP time server + // as an added bonus. + auto nanos = rtc::WinUwpSystemTimeNanos(); struct timeval tv;