diff options
author | Chris Robinson <[email protected]> | 2009-11-01 10:03:05 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2009-11-01 10:03:05 -0800 |
commit | dcd6a55529d70af2d9e39757579dfe67afbda8cf (patch) | |
tree | b729c31a9ba1189c8506ebdc3d6b5c6709bffcce /OpenAL32 | |
parent | fb258a7416a879bc19b92a2bae262d7d709cea72 (diff) |
Use a realtime clock for measuring time
Diffstat (limited to 'OpenAL32')
-rw-r--r-- | OpenAL32/Include/alMain.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index 2fa79574..bc6c6d8b 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -28,6 +28,7 @@ typedef DWORD tls_type; #else +#include <unistd.h> #include <assert.h> #include <pthread.h> #ifdef HAVE_PTHREAD_NP_H @@ -91,13 +92,22 @@ static inline void DeleteCriticalSection(CRITICAL_SECTION *cs) * as opposed to the actual time. */ static inline ALuint timeGetTime(void) { - struct timeval tv; int ret; +#ifdef _POSIX_TIMERS + struct timespec ts; + + ret = clock_gettime(CLOCK_REALTIME, &ts); + assert(ret == 0); + + return ts.tv_nsec/1000000 + ts.tv_sec*1000; +#else + struct timeval tv; ret = gettimeofday(&tv, NULL); assert(ret == 0); return tv.tv_usec/1000 + tv.tv_sec*1000; +#endif } static inline void Sleep(ALuint t) |