X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavutil%2Ftime.c;h=51779c5d177183ce0dd8ecd0b34f018ad89c84d6;hb=9d3009c6c4b9b6734f07df7c88f6a42ded6cdf38;hp=80c4029d9b8b4d75ce059b222c460129c90cae08;hpb=61183b5ab4c203363ee0ee696bdf4819be307230;p=ffmpeg diff --git a/libavutil/time.c b/libavutil/time.c index 80c4029d9b8..51779c5d177 100644 --- a/libavutil/time.c +++ b/libavutil/time.c @@ -20,13 +20,19 @@ #include #include +#include #if HAVE_GETTIMEOFDAY #include -#elif HAVE_GETSYSTEMTIMEASFILETIME +#endif +#if HAVE_UNISTD_H +#include +#endif +#if HAVE_WINDOWS_H #include #endif #include "libavutil/time.h" +#include "error.h" int64_t av_gettime(void) { @@ -44,3 +50,19 @@ int64_t av_gettime(void) return -1; #endif } + +int av_usleep(unsigned usec) +{ +#if HAVE_NANOSLEEP + struct timespec ts = { usec / 1000000, usec % 1000000 * 1000 }; + while (nanosleep(&ts, &ts) < 0 && errno == EINTR); + return 0; +#elif HAVE_USLEEP + return usleep(usec); +#elif HAVE_SLEEP + Sleep(usec / 1000); + return 0; +#else + return AVERROR(ENOSYS); +#endif +}