2 * Copyright (c) 2000-2003 Fabrice Bellard
4 * This file is part of FFmpeg.
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
39 int64_t av_gettime(void)
43 gettimeofday(&tv, NULL);
44 return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
45 #elif HAVE_GETSYSTEMTIMEASFILETIME
48 GetSystemTimeAsFileTime(&ft);
49 t = (int64_t)ft.dwHighDateTime << 32 | ft.dwLowDateTime;
50 return t / 10 - 11644473600000000; /* Jan 1, 1601 */
56 int64_t av_gettime_relative(void)
58 #if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
60 clock_gettime(CLOCK_MONOTONIC, &ts);
61 return (int64_t)ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
67 int av_gettime_relative_is_monotonic(void)
69 #if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
76 int av_usleep(unsigned usec)
79 struct timespec ts = { usec / 1000000, usec % 1000000 * 1000 };
80 while (nanosleep(&ts, &ts) < 0 && errno == EINTR);
88 return AVERROR(ENOSYS);