diff options
author | Uoti Urpala <uau@symbol.nonexistent.invalid> | 2008-04-28 12:09:31 +0300 |
---|---|---|
committer | Uoti Urpala <uau@symbol.nonexistent.invalid> | 2008-04-28 12:18:45 +0300 |
commit | eaf7857b7f7ae6b05ce9d129157e0ff33ed2081b (patch) | |
tree | 17005cd968a137ae8902e408e454cfd32fc033ec /osdep | |
parent | c693b77e935e7e34e21bafed2df0ff891d0e25ac (diff) |
timers: Remove GetRelativeTime()
Move the code calculating time delta since last query out of the
platform-specific drivers and into mplayer.c. The platform-specific
drivers now return absolute values only.
The way the code in timer-darwin.c uses doubles in wrapping arithmetic
looks questionable and this change might make problems in it more
visible.
Diffstat (limited to 'osdep')
-rw-r--r-- | osdep/timer-darwin.c | 21 | ||||
-rw-r--r-- | osdep/timer-linux.c | 13 | ||||
-rw-r--r-- | osdep/timer-win2.c | 11 | ||||
-rw-r--r-- | osdep/timer.h | 1 |
4 files changed, 2 insertions, 44 deletions
diff --git a/osdep/timer-darwin.c b/osdep/timer-darwin.c index 38de7dea9d..e087b33f12 100644 --- a/osdep/timer-darwin.c +++ b/osdep/timer-darwin.c @@ -27,7 +27,6 @@ #include "timer.h" /* global variables */ -static double relative_time, startup_time; static double timebase_ratio; const char timer_name[] = "Darwin accurate"; @@ -54,30 +53,17 @@ int usec_sleep(int usec_delay) /* current time in microseconds */ unsigned int GetTimer() { - return (unsigned int)((mach_absolute_time() * timebase_ratio - startup_time) + return (unsigned int)((mach_absolute_time() * timebase_ratio) * 1e6); } /* current time in milliseconds */ unsigned int GetTimerMS() { - return (unsigned int)((mach_absolute_time() * timebase_ratio - startup_time) + return (unsigned int)((mach_absolute_time() * timebase_ratio) * 1e3); } -/* time spent between now and last call in seconds */ -float GetRelativeTime() -{ - double last_time = relative_time; - - if (!relative_time) - InitTimer(); - - relative_time = mach_absolute_time() * timebase_ratio; - - return (float)(relative_time-last_time); -} - /* initialize timer, must be called at least once at start */ void InitTimer() { @@ -86,9 +72,6 @@ void InitTimer() mach_timebase_info(&timebase); timebase_ratio = (double)timebase.numer / (double)timebase.denom * (double)1e-9; - - relative_time = startup_time = - (double)(mach_absolute_time() * timebase_ratio); } #if 0 diff --git a/osdep/timer-linux.c b/osdep/timer-linux.c index 27e245c850..efcc612627 100644 --- a/osdep/timer-linux.c +++ b/osdep/timer-linux.c @@ -46,21 +46,8 @@ unsigned int GetTimerMS(void){ return (tv.tv_sec*1000+tv.tv_usec/1000); } -static unsigned int RelativeTime=0; - -// Returns time spent between now and last call in seconds -float GetRelativeTime(void){ -unsigned int t,r; - t=GetTimer(); -// t*=16;printf("time=%ud\n",t); - r=t-RelativeTime; - RelativeTime=t; - return (float)r * 0.000001F; -} - // Initialize timer, must be called at least once at start void InitTimer(void){ - GetRelativeTime(); } diff --git a/osdep/timer-win2.c b/osdep/timer-win2.c index ef52a665d3..43c4b07fa9 100644 --- a/osdep/timer-win2.c +++ b/osdep/timer-win2.c @@ -25,16 +25,5 @@ int usec_sleep(int usec_delay){ return 0; } -static DWORD RelativeTime = 0; - -float GetRelativeTime(){ - DWORD t, r; - t = GetTimer(); - r = t - RelativeTime; - RelativeTime = t; - return (float) r *0.000001F; -} - void InitTimer(){ - GetRelativeTime(); } diff --git a/osdep/timer.h b/osdep/timer.h index 44e26cdafc..b0f289c00a 100644 --- a/osdep/timer.h +++ b/osdep/timer.h @@ -7,7 +7,6 @@ void InitTimer(void); unsigned int GetTimer(void); unsigned int GetTimerMS(void); //int uGetTimer(); -float GetRelativeTime(void); int usec_sleep(int usec_delay); |