summaryrefslogtreecommitdiffstats
path: root/src/pulsecore
diff options
context:
space:
mode:
authorMaarten Bosmans <mkbosmans@gmail.com>2011-01-18 11:26:57 +0100
committerMaarten Bosmans <mkbosmans@gmail.com>2011-02-17 12:02:31 +0100
commita39a83665f07a0819a31ee2d1ab60210a67c47a2 (patch)
tree7d60d7abbf98f359f541634557245a8ef642f2dd /src/pulsecore
parent5699954d3360716ad693e0b88596e372afe74443 (diff)
win32: Implement rtclock based on QueryPerformanceCounter
Also remove some unnecessary <time.h> headers.
Diffstat (limited to 'src/pulsecore')
-rw-r--r--src/pulsecore/authkey.c1
-rw-r--r--src/pulsecore/core-rtclock.c30
-rw-r--r--src/pulsecore/core-util.c2
-rw-r--r--src/pulsecore/memblockq.c2
-rw-r--r--src/pulsecore/tagstruct.h1
5 files changed, 30 insertions, 6 deletions
diff --git a/src/pulsecore/authkey.c b/src/pulsecore/authkey.c
index 684bc010..92509d89 100644
--- a/src/pulsecore/authkey.c
+++ b/src/pulsecore/authkey.c
@@ -31,7 +31,6 @@
#include <stdio.h>
#include <inttypes.h>
#include <stdlib.h>
-#include <time.h>
#include <limits.h>
#include <sys/stat.h>
diff --git a/src/pulsecore/core-rtclock.c b/src/pulsecore/core-rtclock.c
index a69b466f..ac2c097a 100644
--- a/src/pulsecore/core-rtclock.c
+++ b/src/pulsecore/core-rtclock.c
@@ -40,12 +40,20 @@
#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);
@@ -88,6 +96,17 @@ struct timeval *pa_rtclock_get(struct timeval *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);
@@ -118,6 +137,11 @@ pa_bool_t pa_rtclock_hrtimer(void) {
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;
@@ -148,6 +172,12 @@ void pa_rtclock_hrtimer_enable(void) {
}
}
+#elif defined(OS_IS_WIN32)
+ LARGE_INTEGER freq;
+
+ pa_assert_se(QueryPerformanceFrequency(&freq));
+ counter_freq = freq.QuadPart;
+
#endif
}
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index 04a2341f..8a377e37 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -34,11 +34,9 @@
#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
diff --git a/src/pulsecore/memblockq.c b/src/pulsecore/memblockq.c
index c7840484..11faedac 100644
--- a/src/pulsecore/memblockq.c
+++ b/src/pulsecore/memblockq.c
@@ -23,8 +23,6 @@
#include <config.h>
#endif
-#include <sys/time.h>
-#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/src/pulsecore/tagstruct.h b/src/pulsecore/tagstruct.h
index 1a99e924..b6553ada 100644
--- a/src/pulsecore/tagstruct.h
+++ b/src/pulsecore/tagstruct.h
@@ -25,7 +25,6 @@
#include <inttypes.h>
#include <sys/types.h>
#include <sys/time.h>
-#include <time.h>
#include <pulse/sample.h>
#include <pulse/channelmap.h>