changeset 15275:0e350095a07b

use sleep_accurate darwin timer
author nplourde
date Wed, 27 Apr 2005 14:55:30 +0000
parents d42539110db9
children f331ff9ff453
files osdep/timer-darwin.c
diffstat 1 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/osdep/timer-darwin.c	Wed Apr 27 12:43:30 2005 +0000
+++ b/osdep/timer-darwin.c	Wed Apr 27 14:55:30 2005 +0000
@@ -34,10 +34,20 @@
 
 
 
+/* 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;
 }