From d59bfa633d84ec3f14ad9ff00a827e2b612e6d28 Mon Sep 17 00:00:00 2001 From: nplourde Date: Wed, 27 Apr 2005 14:55:30 +0000 Subject: [PATCH] use sleep_accurate darwin timer git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@15276 b3059339-0415-0410-9bf9-f77b7e298cf2 --- osdep/timer-darwin.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/osdep/timer-darwin.c b/osdep/timer-darwin.c index 1a9a6e9673..b9b537954b 100644 --- a/osdep/timer-darwin.c +++ b/osdep/timer-darwin.c @@ -34,10 +34,20 @@ const char *timer_name = "Darwin accurate"; +/* the core sleep function, uses floats and is used in MPlayer G2 */ +float sleep_accurate(float time_frame) +{ + uint64_t deadline = time_frame / timebase_ratio + mach_absolute_time(); + + mach_wait_until(deadline); + + return (mach_absolute_time() - deadline) * timebase_ratio; +} + /* wrapper for MPlayer G1 */ int usec_sleep(int usec_delay) { - return usleep(usec_delay); + return sleep_accurate(usec_delay / 1e6) * 1e6; }