]> code.delx.au - pulseaudio/blobdiff - src/pulse/timeval.c
win32: Implement rtclock based on QueryPerformanceCounter
[pulseaudio] / src / pulse / timeval.c
index c4a084192768e85048a5879c61a34d69a85dfcf1..10ba322f067236fa372f9fbf10021ad688e70a02 100644 (file)
 #include "timeval.h"
 
 struct timeval *pa_gettimeofday(struct timeval *tv) {
-#ifdef HAVE_GETTIMEOFDAY
     pa_assert(tv);
 
-    pa_assert_se(gettimeofday(tv, NULL) == 0);
-    return tv;
-#elif defined(OS_IS_WIN32)
+#if defined(OS_IS_WIN32)
     /*
      * Copied from implementation by Steven Edwards (LGPL).
      * Found on wine mailing list.
      */
-
 #if defined(_MSC_VER) || defined(__BORLANDC__)
 #define EPOCHFILETIME (116444736000000000i64)
 #else
 #define EPOCHFILETIME (116444736000000000LL)
 #endif
-
     FILETIME ft;
     LARGE_INTEGER li;
     int64_t t;
 
-    pa_assert(tv);
-
     GetSystemTimeAsFileTime(&ft);
     li.LowPart  = ft.dwLowDateTime;
     li.HighPart = ft.dwHighDateTime;
@@ -68,11 +61,13 @@ struct timeval *pa_gettimeofday(struct timeval *tv) {
     t /= 10;                /* In microseconds */
     tv->tv_sec  = (time_t) (t / PA_USEC_PER_SEC);
     tv->tv_usec = (suseconds_t) (t % PA_USEC_PER_SEC);
-
-    return tv;
+#elif defined(HAVE_GETTIMEOFDAY)
+    pa_assert_se(gettimeofday(tv, NULL) == 0);
 #else
 #error "Platform lacks gettimeofday() or equivalent function."
 #endif
+
+    return tv;
 }
 
 pa_usec_t pa_timeval_diff(const struct timeval *a, const struct timeval *b) {