]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Fix a stupid divide-by-zero error and remove unrecognised warning options for FreeBSD
authorMike Brady <mikebrady@eircom.net>
Mon, 20 Aug 2018 18:53:16 +0000 (19:53 +0100)
committerMike Brady <mikebrady@eircom.net>
Mon, 20 Aug 2018 18:53:16 +0000 (19:53 +0100)
Makefile.am
player.c
rtp.c

index 83fc2132ef0a1f5f77fab32e23ee98b455950991..cc88b5302624f4b2cf13ebc8c3e1f978b81a88b8 100644 (file)
@@ -8,7 +8,7 @@ shairport_sync_SOURCES = shairport.c rtsp.c mdns.c mdns_external.c common.c rtp.
 
 AM_CFLAGS = -Wno-multichar -Wall -Wextra -Wno-clobbered -Wno-psabi -pthread -DSYSCONFDIR=\"$(sysconfdir)\"
 if BUILD_FOR_FREEBSD
-  AM_CXXFLAGS = -I/usr/local/include -Wno-multichar -Wall -Wextra -Wno-clobbered -Wno-psabi -pthread -DSYSCONFDIR=\"$(sysconfdir)\" -O2
+  AM_CXXFLAGS = -I/usr/local/include -Wno-multichar -Wall -Wextra -pthread -DSYSCONFDIR=\"$(sysconfdir)\" -O2
 else
 if BUILD_FOR_OPENBSD
   AM_CXXFLAGS = -I/usr/local/include -Wno-multichar -Wall -Wextra -Wno-clobbered -Wno-psabi -pthread -DSYSCONFDIR=\"$(sysconfdir)\"
index 5853a4acab0d865a169d1b0db147a99dcf63afa7..47758a9a415b39d708913d6a0bed8256756d7414 100644 (file)
--- a/player.c
+++ b/player.c
@@ -2095,8 +2095,12 @@ void *player_thread_func(void *arg) {
 
             int64_t should_be_frame;
             local_time_to_frame(local_time_now, &should_be_frame, conn);
+            
+            int64_t absolute_difference_in_frames = td_in_frames + rt - should_be_frame;
+            if (absolute_difference_in_frames < 0)
+              absolute_difference_in_frames = -absolute_difference_in_frames;
 
-            if (abs(td_in_frames + rt - should_be_frame) > 10 * conn->output_sample_ratio)
+            if (absolute_difference_in_frames > 10 * conn->output_sample_ratio)
               debug(1, "Difference between old and new frame number is %" PRId64 " frames.",
                     td_in_frames + rt - should_be_frame);
             // this is the actual delay, including the latency we actually want, which will
diff --git a/rtp.c b/rtp.c
index 9d3c6f762220b19410a66f5fbc3dd563ba3921f4..5b5b3d3b711f27bba9546e9f0f1803a6bd926804 100644 (file)
--- a/rtp.c
+++ b/rtp.c
@@ -765,35 +765,34 @@ void *rtp_timing_receiver(void *arg) {
                 x_bar += (conn->time_pings[cc].local_time >> 12);
                 sample_count++;
               }
-
-            y_bar = y_bar / sample_count;
-            x_bar = x_bar / sample_count;
-
-            int64_t xid, yid;
-            int64_t mtl, mbl;
-            mtl = 0;
-            mbl = 0;
-            for (cc = 0; cc < conn->time_ping_count; cc++)
-              if ((conn->time_pings[cc].chosen) &&
-                  (conn->time_pings[cc].sequence_number > (settling_time / 3))) {
-
-                uint64_t slt = conn->time_pings[cc].local_time >> 12;
-                if (slt > x_bar)
-                  xid = slt - x_bar;
-                else
-                  xid = -(x_bar - slt);
-
-                uint64_t srt = conn->time_pings[cc].remote_time >> 12;
-                if (srt > y_bar)
-                  yid = srt - y_bar;
-                else
-                  yid = -(y_bar - srt);
-
-                mtl = mtl + xid * yid;
-                mbl = mbl + xid * xid;
-              }
-            conn->local_to_remote_time_gradient_sample_count = sample_count;
             if (sample_count > sample_point_minimum) {
+              y_bar = y_bar / sample_count;
+              x_bar = x_bar / sample_count;
+
+              int64_t xid, yid;
+              int64_t mtl, mbl;
+              mtl = 0;
+              mbl = 0;
+              for (cc = 0; cc < conn->time_ping_count; cc++)
+                if ((conn->time_pings[cc].chosen) &&
+                    (conn->time_pings[cc].sequence_number > (settling_time / 3))) {
+
+                  uint64_t slt = conn->time_pings[cc].local_time >> 12;
+                  if (slt > x_bar)
+                    xid = slt - x_bar;
+                  else
+                    xid = -(x_bar - slt);
+
+                  uint64_t srt = conn->time_pings[cc].remote_time >> 12;
+                  if (srt > y_bar)
+                    yid = srt - y_bar;
+                  else
+                    yid = -(y_bar - srt);
+
+                  mtl = mtl + xid * yid;
+                  mbl = mbl + xid * xid;
+                }
+              conn->local_to_remote_time_gradient_sample_count = sample_count;
               conn->local_to_remote_time_gradient = (1.0 * mtl) / mbl;
               // debug(1,"Drift is %12.2f ppm, based on %d
               // samples.",(1.0-conn->local_to_remote_time_gradient)*1000000,sample_count);