From 8e946e742e6bd75f686cc855f10e8470d5bf71b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Fri, 3 Sep 2004 19:34:01 +0000 Subject: Replace gettimeofday() by better implementation - this fixes astronomic drifts in metronom. MinGW port is working same good as CygWin port (but it means it still isn't for normal usage). And maybe we should add public function xine_gettimeofday() for frontends. There is problem with systems, which haven't gettimeofday(). Replacement function in frontends must then returns exactly the same results as libxine's version. CVS patchset: 6936 CVS date: 2004/09/03 19:34:01 --- win32/contrib/timer/timer.c | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/win32/contrib/timer/timer.c b/win32/contrib/timer/timer.c index 179b7e18f..3b171117c 100644 --- a/win32/contrib/timer/timer.c +++ b/win32/contrib/timer/timer.c @@ -24,41 +24,26 @@ * */ -#include "stdio.h" +#include +#include #include "timer.h" -#include #ifndef SIGALRM #define SIGALRM 14 #endif - /* - this function returns somewhat - accurate unix time with the data - accurate to the first call to get - of day and the resolution accurate - to ~ miliseconds. -*/ -static time_t startseconds = 0; - -int gettimeofday( struct timeval *tp, struct timezone *tzp ) -{ - MMTIME mmtime; +int gettimeofday(struct timeval *tv, struct timezone *tz) { + struct timeb timebuffer; - // clock() returns time in miliseconds + ftime(&timebuffer); + tv->tv_sec = timebuffer.time; + tv->tv_usec = timebuffer.millitm * 1000; - if( !startseconds ) - startseconds = time( 0 ); - - timeGetSystemTime( &mmtime, sizeof( mmtime ) ); - - tp->tv_sec = ( mmtime.u.ms / 1000 ) + startseconds; - tp->tv_usec = ( mmtime.u.ms % 1000 ) * 1000; + return 0; +} - return 0; -}; /* These functions are designed to mimick -- cgit v1.2.3