mirror of https://github.com/mpv-player/mpv
timer: reduce ifdef headsplitting-factor
I'd rather duplicate some trivial code, rather than split functions in the middle with ifdefs.
This commit is contained in:
parent
3620cf97ad
commit
3ca034228d
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* precise timer routines for Linux
|
* precise timer routines for Linux/UNIX
|
||||||
* copyright (C) LGB & A'rpi/ASTRAL
|
* copyright (C) LGB & A'rpi/ASTRAL
|
||||||
*
|
*
|
||||||
* This file is part of MPlayer.
|
* This file is part of MPlayer.
|
||||||
|
@ -26,19 +26,24 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
|
|
||||||
|
#if HAVE_NANOSLEEP
|
||||||
void mp_sleep_us(int64_t us)
|
void mp_sleep_us(int64_t us)
|
||||||
{
|
{
|
||||||
if (us < 0)
|
if (us < 0)
|
||||||
return;
|
return;
|
||||||
#if HAVE_NANOSLEEP
|
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
ts.tv_sec = us / 1000000;
|
ts.tv_sec = us / 1000000;
|
||||||
ts.tv_nsec = (us % 1000000) * 1000;
|
ts.tv_nsec = (us % 1000000) * 1000;
|
||||||
nanosleep(&ts, NULL);
|
nanosleep(&ts, NULL);
|
||||||
#else
|
|
||||||
usleep(us);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
void mp_sleep_us(int64_t us)
|
||||||
|
{
|
||||||
|
if (us < 0)
|
||||||
|
return;
|
||||||
|
usleep(us);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0 && defined(CLOCK_MONOTONIC)
|
#if defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0 && defined(CLOCK_MONOTONIC)
|
||||||
uint64_t mp_raw_time_us(void)
|
uint64_t mp_raw_time_us(void)
|
||||||
|
|
Loading…
Reference in New Issue