mirror of https://github.com/mpv-player/mpv
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:
parent
f9dfc7f46e
commit
d59bfa633d
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue