Mercurial > mplayer.hg
annotate osdep/timer-win2.c @ 10043:89c3480b333c
Small corection of mentioned GCC versions.
author | lumag |
---|---|
date | Thu, 01 May 2003 16:55:54 +0000 |
parents | 14c92818ab75 |
children | 1d5205bab61a |
rev | line source |
---|---|
9983
14c92818ab75
alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff
changeset
|
1 // Precise timer routines for WINDOWS |
14c92818ab75
alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff
changeset
|
2 |
14c92818ab75
alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff
changeset
|
3 #include <windows.h> |
14c92818ab75
alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff
changeset
|
4 #include <mmsystem.h> |
14c92818ab75
alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff
changeset
|
5 #include "timer.h" |
14c92818ab75
alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff
changeset
|
6 |
14c92818ab75
alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff
changeset
|
7 // Returns current time in microseconds |
14c92818ab75
alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff
changeset
|
8 unsigned int GetTimer(){ |
14c92818ab75
alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff
changeset
|
9 return timeGetTime() * 1000; |
14c92818ab75
alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff
changeset
|
10 } |
14c92818ab75
alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff
changeset
|
11 |
14c92818ab75
alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff
changeset
|
12 // Returns current time in milliseconds |
14c92818ab75
alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff
changeset
|
13 unsigned int GetTimerMS(){ |
14c92818ab75
alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff
changeset
|
14 return timeGetTime() ; |
14c92818ab75
alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff
changeset
|
15 } |
14c92818ab75
alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff
changeset
|
16 |
14c92818ab75
alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff
changeset
|
17 int usec_sleep(int usec_delay){ |
14c92818ab75
alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff
changeset
|
18 Sleep( usec_delay/1000); |
14c92818ab75
alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff
changeset
|
19 return 0; |
14c92818ab75
alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff
changeset
|
20 } |
14c92818ab75
alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff
changeset
|
21 |
14c92818ab75
alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff
changeset
|
22 static DWORD RelativeTime = 0; |
14c92818ab75
alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff
changeset
|
23 |
14c92818ab75
alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff
changeset
|
24 float GetRelativeTime(){ |
14c92818ab75
alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff
changeset
|
25 DWORD t, r; |
14c92818ab75
alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff
changeset
|
26 t = GetTimer(); |
14c92818ab75
alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff
changeset
|
27 r = t - RelativeTime; |
14c92818ab75
alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff
changeset
|
28 RelativeTime = t; |
14c92818ab75
alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff
changeset
|
29 return (float) r *0.000001F; |
14c92818ab75
alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff
changeset
|
30 } |
14c92818ab75
alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff
changeset
|
31 |
14c92818ab75
alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff
changeset
|
32 void InitTimer(){ |
14c92818ab75
alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff
changeset
|
33 GetRelativeTime(); |
14c92818ab75
alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff
changeset
|
34 } |