drivers/timers_win32/timers_win32.c
changeset 680 9a2474509269
parent 629 b9274b595650
child 697 24a2aec61731
--- a/drivers/timers_win32/timers_win32.c	Thu Dec 22 13:46:00 2011 +0100
+++ b/drivers/timers_win32/timers_win32.c	Thu May 12 12:23:20 2011 +0000
@@ -38,7 +38,7 @@
 };
 #endif
 
-struct _timeb timebuffer;
+DWORD timebuffer;
 
 /* Synchronization Object Implementation */
 CRITICAL_SECTION CanFestival_mutex;
@@ -90,8 +90,8 @@
 		WaitForSingleObject(timer, INFINITE);
 		if(stop_timer)
 			break;
-		_ftime(&timebuffer);
 		EnterMutex();
+		timebuffer = GetTickCount();
 		TimeDispatch();
 		LeaveMutex();
 	}
@@ -112,7 +112,7 @@
     }
 
 	// Take first absolute time ref in milliseconds.
-	_ftime(&timebuffer);
+	timebuffer = GetTickCount();
 }
 
 void TimerCleanup(void)
@@ -158,7 +158,7 @@
 		LARGE_INTEGER liDueTime;
 
 		/* arg 2 of SetWaitableTimer take 100 ns interval */
-		liDueTime.QuadPart = (-1 * value);
+		liDueTime.QuadPart = ((long long) (-1) * value * 10000);
 		//printf("SetTimer(%llu)\n", value);
 
 		if (!SetWaitableTimer(timer, &liDueTime, 0, NULL, NULL, FALSE))
@@ -171,8 +171,7 @@
 /* Get the elapsed time since the last occured alarm */
 TIMEVAL getElapsedTime(void)
 {
-	struct _timeb timetmp;
-	_ftime(&timetmp);
-	return (timetmp.time - timebuffer.time) * 10000000 + (timetmp.millitm - timebuffer.millitm) * 10000;
+  DWORD timetmp = GetTickCount();
+  return (timetmp - timebuffer);
 }