Browse Source

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.
tags/0.126.0
Adrian Knoth 7 years ago
parent
commit
8799147e66
2 changed files with 10 additions and 10 deletions
  1. +1
    -1
      jackd/engine.c
  2. +9
    -9
      libjack/time.c

+ 1
- 1
jackd/engine.c View File

@@ -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;


+ 9
- 9
libjack/time.c View File

@@ -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;
}



Loading…
Cancel
Save