summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrantišek Dvořák <valtri@users.sourceforge.net>2004-09-03 19:34:01 +0000
committerFrantišek Dvořák <valtri@users.sourceforge.net>2004-09-03 19:34:01 +0000
commit8e946e742e6bd75f686cc855f10e8470d5bf71b6 (patch)
tree9efbbc37228879fb0d2e9fab9a8a8908ae30c08a
parentd2f0a7f044b76fa876e80232656c6fca94a8e596 (diff)
downloadxine-lib-8e946e742e6bd75f686cc855f10e8470d5bf71b6.tar.gz
xine-lib-8e946e742e6bd75f686cc855f10e8470d5bf71b6.tar.bz2
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
-rw-r--r--win32/contrib/timer/timer.c33
1 files 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 <sys/timeb.h>
+#include <signal.h>
#include "timer.h"
-#include <signal.h>
#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