Also remove some unnecessary <time.h> headers.
#include <inttypes.h>
#include <sys/time.h>
-#include <time.h>
#include <pulse/cdecl.h>
#include <pulse/sample.h>
***/
#include <sys/time.h>
-#include <time.h>
#include <pulse/cdecl.h>
#include <pulse/sample.h>
#include <config.h>
#endif
+#include <pulse/timeval.h>
#include <pulsecore/core-rtclock.h>
#include "rtclock.h"
-#include "timeval.h"
pa_usec_t pa_rtclock_now(void) {
struct timeval tv;
#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;
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) {
#include <stdio.h>
#include <inttypes.h>
#include <stdlib.h>
-#include <time.h>
#include <limits.h>
#include <sys/stat.h>
#include <unistd.h>
#endif
+#ifdef HAVE_WINDOWS_H
+#include <windows.h>
+#endif
+
#include <pulse/timeval.h>
#include <pulsecore/macro.h>
#include <pulsecore/core-error.h>
#include "core-rtclock.h"
+#ifdef OS_IS_WIN32
+static int64_t counter_freq = 0;
+#endif
+
pa_usec_t pa_rtclock_age(const struct timeval *tv) {
struct timeval now;
pa_assert(tv);
tv->tv_usec = ts.tv_nsec / PA_NSEC_PER_USEC;
return tv;
+#elif defined(OS_IS_WIN32)
+ if (counter_freq > 0) {
+ LARGE_INTEGER count;
+
+ pa_assert_se(QueryPerformanceCounter(&count));
+
+ tv->tv_sec = count.QuadPart / counter_freq;
+ tv->tv_usec = (count.QuadPart % counter_freq) * PA_USEC_PER_SEC / counter_freq;
+
+ return tv;
+ }
#endif /* HAVE_CLOCK_GETTIME */
return pa_gettimeofday(tv);
pa_assert_se(clock_getres(CLOCK_REALTIME, &ts) == 0);
return ts.tv_sec == 0 && ts.tv_nsec <= (long) (PA_HRTIMER_THRESHOLD_USEC*PA_NSEC_PER_USEC);
+#elif defined(OS_IS_WIN32)
+
+ if (counter_freq > 0)
+ return counter_freq >= (int64_t) (PA_USEC_PER_SEC/PA_HRTIMER_THRESHOLD_USEC);
+
#endif /* HAVE_CLOCK_GETTIME */
return FALSE;
}
}
+#elif defined(OS_IS_WIN32)
+ LARGE_INTEGER freq;
+
+ pa_assert_se(QueryPerformanceFrequency(&freq));
+ counter_freq = freq.QuadPart;
+
#endif
}
#include <fcntl.h>
#include <unistd.h>
#include <limits.h>
-#include <time.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include <sys/time.h>
#include <dirent.h>
#ifdef HAVE_LANGINFO_H
#include <config.h>
#endif
-#include <sys/time.h>
-#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include <sys/types.h>
#include <sys/time.h>
-#include <time.h>
#include <pulse/sample.h>
#include <pulse/channelmap.h>