summaryrefslogtreecommitdiffstats
path: root/osdep/timer-win2.c
diff options
context:
space:
mode:
Diffstat (limited to 'osdep/timer-win2.c')
-rw-r--r--osdep/timer-win2.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/osdep/timer-win2.c b/osdep/timer-win2.c
index 136bb0becc..ed09ed18db 100644
--- a/osdep/timer-win2.c
+++ b/osdep/timer-win2.c
@@ -21,6 +21,7 @@
#include <windows.h>
#include <sys/time.h>
#include <mmsystem.h>
+#include <stdlib.h>
#include "timer.h"
void mp_sleep_us(int64_t us)
@@ -42,8 +43,15 @@ uint64_t mp_raw_time_us(void)
return tv.tv_sec * 1000000LL + tv.tv_usec;
}
+static void restore_timer(void)
+{
+ // The MSDN documents that begin/end "must" be matched. This satisfies
+ // this requirement.
+ timeEndPeriod(1);
+}
+
void mp_raw_time_init(void)
{
- // request 1ms timer resolution
- timeBeginPeriod(1);
+ timeBeginPeriod(1); // request 1ms timer resolution
+ atexit(restore_timer);
}