summaryrefslogtreecommitdiffstats
path: root/osdep
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-05-25 18:31:06 +0200
committerwm4 <wm4@nowhere>2013-05-26 16:44:20 +0200
commite56d8a200d900066c3da571d92733f66ce6a13ab (patch)
treef43862ec12beee05380da82ebef23bcce83401e7 /osdep
parent51254a678c386cf48f2caa51e06ad34065c8693a (diff)
downloadmpv-e56d8a200d900066c3da571d92733f66ce6a13ab.tar.bz2
mpv-e56d8a200d900066c3da571d92733f66ce6a13ab.tar.xz
Replace all calls to GetTimer()/GetTimerMS()
GetTimer() is generally replaced with mp_time_us(). Both calls return microseconds, but the latter uses int64_t, us defined to never wrap, and never returns 0 or negative values. GetTimerMS() has no direct replacement. Instead the other functions are used. For some code, switch to mp_time_sec(), which returns the time as double float value in seconds. The returned time is offset to program start time, so there is enough precision left to deliver microsecond resolution for at least 100 years. Unless it's casted to a float (or the CPU reduces precision), which is why we still use mp_time_us() out of paranoia in places where precision is clearly needed. Always switch to the correct time. The whole point of the new timer calls is that they don't wrap, and storing microseconds in unsigned int variables would negate this. In some cases, remove wrap-around handling for time values.
Diffstat (limited to 'osdep')
-rw-r--r--osdep/timer.c10
-rw-r--r--osdep/timer.h2
2 files changed, 0 insertions, 12 deletions
diff --git a/osdep/timer.c b/osdep/timer.c
index 2304bb1297..c1efeff8b5 100644
--- a/osdep/timer.c
+++ b/osdep/timer.c
@@ -42,16 +42,6 @@ double mp_time_sec(void)
return mp_time_us() / (double)(1000 * 1000);
}
-unsigned int GetTimer(void)
-{
- return mp_time_us();
-}
-
-unsigned int GetTimerMS(void)
-{
- return (mp_time_us() + 500) / 1000;
-}
-
int usec_sleep(int usec_delay)
{
mp_sleep_us(usec_delay);
diff --git a/osdep/timer.h b/osdep/timer.h
index 033b366750..bdddf3d61a 100644
--- a/osdep/timer.h
+++ b/osdep/timer.h
@@ -39,8 +39,6 @@ uint64_t mp_raw_time_us(void);
void mp_sleep_us(int64_t us);
// Legacy timer functions. These can wrap.
-unsigned int GetTimer(void); // in us
-unsigned int GetTimerMS(void); // in ms
int usec_sleep(int usec_delay);
#endif /* MPLAYER_TIMER_H */