diff options
author | Adrian Knoth <adi@drcomp.erfurt.thur.de> | 2017-01-10 00:41:29 +0100 |
---|---|---|
committer | Adrian Knoth <adi@drcomp.erfurt.thur.de> | 2017-01-10 00:41:29 +0100 |
commit | 8799147e66e25d3e6823ce9d6048c3ae9ee18ce9 (patch) | |
tree | 5ce84a2f2540aab8918c100bfaa4ac33c4d22ae6 | |
parent | 5bb11a71f48de1e361731224abe83e3e79d7b905 (diff) | |
download | jack1-8799147e66e25d3e6823ce9d6048c3ae9ee18ce9.tar.gz |
Use #if for HAVE_CLOCK_GETTIME everywhere
ifdef is useless, since the value is always defined (either to 1 or 0) in config.h.
Fix inspired by
https://svnweb.freebsd.org/ports/head/audio/jack/files/patch-drivers_dummy_dummy__driver.c?view=markup
Also simplified #if condition in libjack/time.c - it's easier to read a positive than a negated
condition.
-rw-r--r-- | jackd/engine.c | 2 | ||||
-rw-r--r-- | libjack/time.c | 18 |
2 files changed, 10 insertions, 10 deletions
diff --git a/jackd/engine.c b/jackd/engine.c index ad0a8d6..1235815 100644 --- a/jackd/engine.c +++ b/jackd/engine.c @@ -627,7 +627,7 @@ jack_process_internal (jack_engine_t *engine, JSList *node, to know that that jack_get_microseconds() is monotonic. */ -#ifdef HAVE_CLOCK_GETTIME +#if HAVE_CLOCK_GETTIME static const int system_clock_monotonic = 1; #else static const int system_clock_monotonic = 0; diff --git a/libjack/time.c b/libjack/time.c index f476ebf..7c6ac91 100644 --- a/libjack/time.c +++ b/libjack/time.c @@ -48,7 +48,7 @@ jack_clock_source_name (jack_timer_type_t src) case JACK_TIMER_HPET: return "hpet"; case JACK_TIMER_SYSTEM_CLOCK: -#ifdef HAVE_CLOCK_GETTIME +#if HAVE_CLOCK_GETTIME return "system clock via clock_gettime"; #else return "system clock via gettimeofday"; @@ -60,16 +60,17 @@ jack_clock_source_name (jack_timer_type_t src) return "unknown"; } -#ifndef HAVE_CLOCK_GETTIME +#if HAVE_CLOCK_GETTIME jack_time_t jack_get_microseconds_from_system (void) { jack_time_t jackTime; - struct timeval tv; + struct timespec time; - gettimeofday (&tv, NULL); - jackTime = (jack_time_t)tv.tv_sec * 1000000 + (jack_time_t)tv.tv_usec; + clock_gettime (CLOCK_MONOTONIC, &time); + jackTime = (jack_time_t)time.tv_sec * 1e6 + + (jack_time_t)time.tv_nsec / 1e3; return jackTime; } @@ -79,11 +80,10 @@ jack_time_t jack_get_microseconds_from_system (void) { jack_time_t jackTime; - struct timespec time; + struct timeval tv; - clock_gettime (CLOCK_MONOTONIC, &time); - jackTime = (jack_time_t)time.tv_sec * 1e6 + - (jack_time_t)time.tv_nsec / 1e3; + gettimeofday (&tv, NULL); + jackTime = (jack_time_t)tv.tv_sec * 1000000 + (jack_time_t)tv.tv_usec; return jackTime; } |