Subversion Repositories Kolibri OS

Rev

Rev 6147 | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. /*
  2.  * Copyright (c) 2000-2003 Fabrice Bellard
  3.  *
  4.  * This file is part of FFmpeg.
  5.  *
  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.
  10.  *
  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.
  15.  *
  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
  19.  */
  20.  
  21. #define _GNU_SOURCE
  22.  
  23. #include "config.h"
  24.  
  25. #include <stddef.h>
  26. #include <stdint.h>
  27. #include <time.h>
  28. #if HAVE_GETTIMEOFDAY
  29. #include <sys/time.h>
  30. #endif
  31. #if HAVE_UNISTD_H
  32. #include <unistd.h>
  33. #endif
  34. #if HAVE_WINDOWS_H
  35. #include <windows.h>
  36. #endif
  37.  
  38. #include "time.h"
  39. #include "error.h"
  40.  
  41. int64_t av_gettime(void)
  42. {
  43. #if HAVE_GETTIMEOFDAY
  44.     struct timeval tv;
  45.     gettimeofday(&tv, NULL);
  46.     return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
  47. #elif HAVE_GETSYSTEMTIMEASFILETIME
  48.     FILETIME ft;
  49.     int64_t t;
  50.     GetSystemTimeAsFileTime(&ft);
  51.     t = (int64_t)ft.dwHighDateTime << 32 | ft.dwLowDateTime;
  52.     return t / 10 - 11644473600000000; /* Jan 1, 1601 */
  53. #else
  54.     return -1;
  55. #endif
  56. }
  57.  
  58. int64_t av_gettime_relative(void)
  59. {
  60. #if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
  61.     struct timespec ts;
  62.     clock_gettime(CLOCK_MONOTONIC, &ts);
  63.     return (int64_t)ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
  64. #else
  65.     return av_gettime() + 42 * 60 * 60 * INT64_C(1000000);
  66. #endif
  67. }
  68.  
  69. int av_gettime_relative_is_monotonic(void)
  70. {
  71. #if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
  72.     return 1;
  73. #else
  74.     return 0;
  75. #endif
  76. }
  77.  
  78. int av_usleep(unsigned usec)
  79. {
  80.     return AVERROR(ENOSYS);
  81. }
  82.