]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Fix a stupid bug in the selection of timebases.
authorMike Brady <4265913+mikebrady@users.noreply.github.com>
Mon, 23 May 2022 19:34:37 +0000 (20:34 +0100)
committerMike Brady <4265913+mikebrady@users.noreply.github.com>
Mon, 23 May 2022 19:34:37 +0000 (20:34 +0100)
common.c
player.c

index 5112d7cd58bf89a590f2d543294c841c7389d775..a21dc9c4fce76d4316a49cdd083ef743e3a45d2f 100644 (file)
--- a/common.c
+++ b/common.c
@@ -1211,61 +1211,7 @@ uint64_t get_monotonic_time_in_ns() {
 
 #ifdef COMPILE_FOR_LINUX_AND_FREEBSD_AND_CYGWIN_AND_OPENBSD
   struct timespec tn;
-#ifdef CLOCK_MONOTONIC_RAW
-  clock_gettime(CLOCK_MONOTONIC_RAW, &tn);
-#else
-  clock_gettime(CLOCK_MONOTONIC, &tn);
-#endif
-  uint64_t tnnsec = tn.tv_sec;
-  tnnsec = tnnsec * 1000000000;
-  uint64_t tnjnsec = tn.tv_nsec;
-  time_now_ns = tnnsec + tnjnsec;
-#endif
-
-#ifdef COMPILE_FOR_OSX
-  uint64_t time_now_mach;
-  uint64_t elapsedNano;
-  static mach_timebase_info_data_t sTimebaseInfo = {0, 0};
-
-  // this actually give you a monotonic clock
-  // see https://news.ycombinator.com/item?id=6303755
-  time_now_mach = mach_absolute_time();
-
-  // If this is the first time we've run, get the timebase.
-  // We can use denom == 0 to indicate that sTimebaseInfo is
-  // uninitialised because it makes no sense to have a zero
-  // denominator in a fraction.
-
-  if (sTimebaseInfo.denom == 0) {
-    debug(1, "Mac initialise timebase info.");
-    (void)mach_timebase_info(&sTimebaseInfo);
-  }
-
-  if (sTimebaseInfo.denom == 0)
-    die("could not initialise Mac timebase info in get_monotonic_time_in_ns().")
-
-        // Do the maths. We hope that the multiplication doesn't
-        // overflow; the price you pay for working in fixed point.
-
-        // this gives us nanoseconds
-        time_now_ns = time_now_mach * sTimebaseInfo.numer / sTimebaseInfo.denom;
-#endif
-
-  return time_now_ns;
-}
-
-// all these clock things are now in macOS now since 10.13 (September 2017). Must update...
-uint64_t get_monotonic_raw_time_in_ns() {
-  // CLOCK_MONOTONIC_RAW/CLOCK_MONOTONIC in Linux/FreeBSD etc, monotonic in MacOSX
-  uint64_t time_now_ns;
-
-#ifdef COMPILE_FOR_LINUX_AND_FREEBSD_AND_CYGWIN_AND_OPENBSD
-  struct timespec tn;
-#ifdef CLOCK_MONOTONIC_RAW
-  clock_gettime(CLOCK_MONOTONIC_RAW, &tn);
-#else
   clock_gettime(CLOCK_MONOTONIC, &tn);
-#endif
   uint64_t tnnsec = tn.tv_sec;
   tnnsec = tnnsec * 1000000000;
   uint64_t tnjnsec = tn.tv_nsec;
@@ -1308,13 +1254,8 @@ uint64_t get_monotonic_raw_time_in_ns() {
 // Not defined for macOS
 uint64_t get_realtime_in_ns() {
   uint64_t time_now_ns;
-
   struct timespec tn;
-#ifdef CLOCK_MONOTONIC_RAW
-  clock_gettime(CLOCK_MONOTONIC_RAW, &tn);
-#else
-  clock_gettime(CLOCK_MONOTONIC, &tn);
-#endif
+  clock_gettime(CLOCK_REALTIME, &tn);
   uint64_t tnnsec = tn.tv_sec;
   tnnsec = tnnsec * 1000000000;
   uint64_t tnjnsec = tn.tv_nsec;
index 9031e229de0a4d52fb7a226007bebc01bb899967..0eb6b2dfa885bd8df358956be6cc75595bcd1b52 100644 (file)
--- a/player.c
+++ b/player.c
@@ -1321,7 +1321,7 @@ static abuf_t *buffer_get_frame(rtsp_conn_info *conn) {
       struct timespec time_of_wakeup;
       time_of_wakeup.tv_sec = sec;
       time_of_wakeup.tv_nsec = nsec;
-      //      pthread_cond_timedwait(&conn->flowcontrol, &conn->ab_mutex, &time_of_wakeup);
+
       int rc = pthread_cond_timedwait(&conn->flowcontrol, &conn->ab_mutex,
                                       &time_of_wakeup); // this is a pthread cancellation point
       if ((rc != 0) && (rc != ETIMEDOUT))