Index: webrtc/base/task_queue_win.cc |
diff --git a/webrtc/base/task_queue_win.cc b/webrtc/base/task_queue_win.cc |
index 5850b2947ed2822f1d646efbff6a00af91343854..17bb3277596f1939fdeacf1536972d96f62116e4 100644 |
--- a/webrtc/base/task_queue_win.cc |
+++ b/webrtc/base/task_queue_win.cc |
@@ -66,6 +66,16 @@ ThreadPriority TaskQueuePriorityToThreadPriority(Priority priority) { |
} |
return kNormalPriority; |
} |
+ |
+DWORD GetTick() { |
+ static const UINT kPeriod = 1; |
+ bool high_res = (timeBeginPeriod(kPeriod) == TIMERR_NOERROR); |
+ DWORD ret = timeGetTime(); |
henrika_webrtc
2017/03/03 12:24:55
What happens if high_res is false?
tommi
2017/03/03 12:39:01
Default behavior of timeGetTime():
https://msdn.m
henrika_webrtc
2017/03/03 12:42:32
Got it. I was more thinking about what will be ret
tommi
2017/03/03 12:59:34
TIMERR_NOCANDO is one possibility. I don't think t
henrika_webrtc
2017/03/03 13:00:53
Sorry. My brain added a {} below and I therefore f
tommi
2017/03/03 13:10:21
ack :)
|
+ if (high_res) |
+ timeEndPeriod(kPeriod); |
+ return ret; |
+} |
+ |
} // namespace |
class TaskQueue::MultimediaTimer { |
@@ -214,7 +224,7 @@ void TaskQueue::PostDelayedTask(std::unique_ptr<QueuedTask> task, |
// GetTickCount() returns a fairly coarse tick count (resolution or about 8ms) |
// so this compensation isn't that accurate, but since we have unused 32 bits |
// on Win64, we might as well use them. |
- wparam = (static_cast<WPARAM>(::GetTickCount()) << 32) | milliseconds; |
+ wparam = (static_cast<WPARAM>(GetTick()) << 32) | milliseconds; |
#else |
wparam = milliseconds; |
#endif |
@@ -325,7 +335,7 @@ bool TaskQueue::ProcessQueuedMessages(DelayedTasks* delayed_tasks, |
uint32_t milliseconds = msg.wParam & 0xFFFFFFFF; |
#if defined(_WIN64) |
// Subtract the time it took to queue the timer. |
- const DWORD now = GetTickCount(); |
+ const DWORD now = GetTick(); |
DWORD post_time = now - (msg.wParam >> 32); |
milliseconds = |
post_time > milliseconds ? 0 : milliseconds - post_time; |