use sleep_accurate darwin timer

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@15276 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
nplourde 2005-04-27 14:55:30 +00:00
parent f9dfc7f46e
commit d59bfa633d
1 changed files with 11 additions and 1 deletions

View File

@ -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;
}