annotate osdep/timer-win2.c @ 25957:0a3b2b2cc1c3

Implement test for system byteswap.h header file. The result of this check is required by libavutil library. If it is not defined the library would try to implement its own byte swapping routines in bswap.h . As the routines are with same names, if included, the system definition would replace the function names with the macros. The result can not be compiled and looks like this: # 42 "../libavutil/bswap.h" -static av_always_inline uint16_t bswap_16(uint16_t x) +static __attribute__((always_inline)) inline uint16_t (__extension__ ({ register unsigned short int __v, __x = (uint16_t x); if (__builtin_constant_p (__x)) __v = ((((__x) >> 8) & 0xff) | (((__x) & 0xff) << 8)); else __asm__ ("rorw $8, %w0" : "=r" (__v) : "0" (__x) : "cc"); __v; }))
author iive
date Tue, 12 Feb 2008 21:10:13 +0000
parents f9755d9c479a
children 8df85ad26746
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
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
10 unsigned int GetTimer(){
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
11 return timeGetTime() * 1000;
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
12 }
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 // Returns current time in milliseconds
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
15 unsigned int GetTimerMS(){
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
16 return timeGetTime() ;
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
17 }
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
18
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
19 int usec_sleep(int usec_delay){
11480
1d5205bab61a Sleep(0) != usleep(0), bugreport by Paul-Kenji Cahier
faust3
parents: 9983
diff changeset
20 // 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
21 // instead it will only make the thread ready
1d5205bab61a Sleep(0) != usleep(0), bugreport by Paul-Kenji Cahier
faust3
parents: 9983
diff changeset
22 // 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
23 if(usec_delay<1000)usec_delay=1000;
9983
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
24 Sleep( usec_delay/1000);
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
25 return 0;
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
26 }
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
27
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
28 static DWORD RelativeTime = 0;
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 float GetRelativeTime(){
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
31 DWORD t, r;
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
32 t = GetTimer();
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
33 r = t - RelativeTime;
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
34 RelativeTime = t;
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
35 return (float) r *0.000001F;
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
36 }
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
37
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
38 void InitTimer(){
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
39 GetRelativeTime();
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
40 }