annotate osdep/timer-win2.c @ 28282:31849f6ac0c7

Sync with latest FFmpeg changes: #define disabled preprocessor directives used by FFmpeg to 0 instead of leaving them undefined.
author diego
date Thu, 15 Jan 2009 15:56:24 +0000
parents 8d6c3abed492
children 5cfef41a1771
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
12954
f9755d9c479a Native darwin timer update.
wight
parents: 11480
diff changeset
7 const char *timer_name = "Windows native";
f9755d9c479a Native darwin timer update.
wight
parents: 11480
diff changeset
8
9983
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
9 // Returns current time in microseconds
28232
8df85ad26746 Add missing 'void' keyword to parameterless function declarations.
diego
parents: 12954
diff changeset
10 unsigned int GetTimer(void)
8df85ad26746 Add missing 'void' keyword to parameterless function declarations.
diego
parents: 12954
diff changeset
11 {
9983
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
12 return timeGetTime() * 1000;
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
13 }
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
14
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
15 // Returns current time in milliseconds
28234
8d6c3abed492 timer-win2.c: Fix "voi" (void) typo breaking Windows compilation
uau
parents: 28232
diff changeset
16 unsigned int GetTimerMS(void)
28232
8df85ad26746 Add missing 'void' keyword to parameterless function declarations.
diego
parents: 12954
diff changeset
17 {
9983
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
18 return timeGetTime() ;
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
19 }
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 int usec_sleep(int usec_delay){
11480
1d5205bab61a Sleep(0) != usleep(0), bugreport by Paul-Kenji Cahier
faust3
parents: 9983
diff changeset
22 // Sleep(0) won't sleep for one clocktick as the unix usleep
1d5205bab61a Sleep(0) != usleep(0), bugreport by Paul-Kenji Cahier
faust3
parents: 9983
diff changeset
23 // instead it will only make the thread ready
1d5205bab61a Sleep(0) != usleep(0), bugreport by Paul-Kenji Cahier
faust3
parents: 9983
diff changeset
24 // it may take some time until it actually starts to run again
1d5205bab61a Sleep(0) != usleep(0), bugreport by Paul-Kenji Cahier
faust3
parents: 9983
diff changeset
25 if(usec_delay<1000)usec_delay=1000;
9983
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
26 Sleep( usec_delay/1000);
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
27 return 0;
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
28 }
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
29
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
30 static DWORD RelativeTime = 0;
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
31
28232
8df85ad26746 Add missing 'void' keyword to parameterless function declarations.
diego
parents: 12954
diff changeset
32 float GetRelativeTime(void)
8df85ad26746 Add missing 'void' keyword to parameterless function declarations.
diego
parents: 12954
diff changeset
33 {
9983
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
34 DWORD t, r;
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
35 t = GetTimer();
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
36 r = t - RelativeTime;
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
37 RelativeTime = t;
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
38 return (float) r *0.000001F;
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
39 }
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
40
28232
8df85ad26746 Add missing 'void' keyword to parameterless function declarations.
diego
parents: 12954
diff changeset
41 void InitTimer(void)
8df85ad26746 Add missing 'void' keyword to parameterless function declarations.
diego
parents: 12954
diff changeset
42 {
9983
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
43 GetRelativeTime();
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
44 }