Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(725)

Unified Diff: webrtc/base/task_queue_win.cc

Issue 2728663008: Increase tick precision in TaskQueue on Windows 64. (Closed)
Patch Set: Only define GetTick for win64 Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/base/task_queue_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..bbaf7b9f44b4383feff79fd08697fea4e08c7e6b 100644
--- a/webrtc/base/task_queue_win.cc
+++ b/webrtc/base/task_queue_win.cc
@@ -66,6 +66,17 @@ ThreadPriority TaskQueuePriorityToThreadPriority(Priority priority) {
}
return kNormalPriority;
}
+
+#if defined(_WIN64)
+DWORD GetTick() {
+ static const UINT kPeriod = 1;
+ bool high_res = (timeBeginPeriod(kPeriod) == TIMERR_NOERROR);
+ DWORD ret = timeGetTime();
+ if (high_res)
+ timeEndPeriod(kPeriod);
+ return ret;
+}
+#endif
} // namespace
class TaskQueue::MultimediaTimer {
@@ -214,7 +225,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 +336,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;
« no previous file with comments | « webrtc/base/task_queue_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698