]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Move to using pthread_cancel in place of pthread_kill -- due to a problem in CYGWIN...
authorMike Brady <mikebrady@eircom.net>
Thu, 17 May 2018 09:29:59 +0000 (10:29 +0100)
committerMike Brady <mikebrady@eircom.net>
Thu, 17 May 2018 09:29:59 +0000 (10:29 +0100)
audio_ao.c
mdns.c
player.c
rtp.c

index 9c87f892df09cc4101416b31e20d6f040d4c3b7e..8a78e88045d2811c75d4336b2afa17d3a17c8ac2 100644 (file)
@@ -121,7 +121,7 @@ static void deinit(void) {
 static void start(__attribute__((unused)) int sample_rate,
                   __attribute__((unused)) int sample_format) {}
 
-static void play(void * buf, int samples) { ao_play(dev, buf, samples * 4); }
+static void play(void *buf, int samples) { ao_play(dev, buf, samples * 4); }
 
 static void stop(void) {}
 
diff --git a/mdns.c b/mdns.c
index f6a191a3d65b273e6774bb23bf8557933380248b..b8d870c6fecea965772840369f206c07e6f47b16 100644 (file)
--- a/mdns.c
+++ b/mdns.c
@@ -106,14 +106,14 @@ void mdns_unregister(void) {
 
 void *mdns_dacp_monitor(char *dacp_id) {
   void *reply = NULL;
-  if ((dacp_id!=NULL) && (*dacp_id!='\0')) {
-  if ((config.mdns) && (config.mdns->mdns_dacp_monitor)) {
-    reply = config.mdns->mdns_dacp_monitor(dacp_id);
-    if (reply == NULL) {
-      debug(1, "Error starting a DACP monitor.");
-    }
-  } else
-    debug(3, "Can't start a DACP monitor -- none registered.");
+  if ((dacp_id != NULL) && (*dacp_id != '\0')) {
+    if ((config.mdns) && (config.mdns->mdns_dacp_monitor)) {
+      reply = config.mdns->mdns_dacp_monitor(dacp_id);
+      if (reply == NULL) {
+        debug(1, "Error starting a DACP monitor.");
+      }
+    } else
+      debug(3, "Can't start a DACP monitor -- none registered.");
   }
   return reply;
 }
index 41199da9755e0290072304a8da42ee5852e770de..8e29678aadc429c23c7174334e9f7b8a5f35d28f 100644 (file)
--- a/player.c
+++ b/player.c
@@ -545,8 +545,9 @@ void player_put_packet(seq_t seqno, uint32_t actual_timestamp, int64_t timestamp
                   if (config.disable_resend_requests == 0) {
                     rtp_request_resend(next, 1, conn);
                     if ((back_step + k + resend_interval) >= sd)
-                      debug(2, "Last-ditch (#%d) resend request for packet %u in range %u to %u. Looking back %d packets.", j, next,
-                            conn->ab_read, conn->ab_write,back_step + k);
+                      debug(2, "Last-ditch (#%d) resend request for packet %u in range %u to %u. "
+                               "Looking back %d packets.",
+                            j, next, conn->ab_read, conn->ab_write, back_step + k);
                     conn->resend_requests++;
                   }
                 }
diff --git a/rtp.c b/rtp.c
index a900c7a4c5b117911c3943f9bf10ff3e88e3c03f..e15c18ad34d2d08b757b7a08a97c1c1057b89719 100644 (file)
--- a/rtp.c
+++ b/rtp.c
@@ -177,7 +177,7 @@ void *rtp_audio_receiver(void *arg) {
   debug(3, "Audio receiver -- Server RTP thread interrupted. terminating.");
   close(conn->audio_socket);
   */
-  
+
   debug(1, "Audio receiver thread \"normal\" exit -- this can't happen. Hah!");
   pthread_cleanup_pop(0); // don't execute anything here.
   debug(2, "Audio receiver thread exit.");
@@ -211,50 +211,50 @@ void *rtp_control_receiver(void *arg) {
           (drand48() > config.diagnostic_drop_packet_fraction)) {
 
         ssize_t plen = nread;
-        if (packet[1] == 0xd4) {                     // sync data
-      /*
-           // the following stanza is for debugging only -- normally commented out.
-           {
-             char obf[4096];
-             char *obfp = obf;
-             int obfc;
-             for (obfc = 0; obfc < plen; obfc++) {
-               snprintf(obfp, 3, "%02X", packet[obfc]);
-               obfp += 2;
-             };
-             *obfp = 0;
-
-
-             // get raw timestamp information
-             // I think that a good way to understand these timestamps is that
-             // (1) the rtlt below is the timestamp of the frame that should be playing at the
-             // client-time specified in the packet if there was no delay
-             // and (2) that the rt below is the timestamp of the frame that should be playing
-             // at the client-time specified in the packet on this device taking account of
-             // the delay
-             // Thus, (3) the latency can be calculated by subtracting the second from the
-             // first.
-             // There must be more to it -- there something missing.
-
-             // In addition, it seems that if the value of the short represented by the second
-             // pair of bytes in the packe is 7
-             // then an extra time lag is expected to be added, presumably by
-             // the AirPort Express.
-             
-             // Best guess is that this delay is 11,025 frames.
-
-             // uint32_t rtlt = nctohl(&packet[4]); // raw timestamp less latency
-             // uint32_t rt = nctohl(&packet[16]);  // raw timestamp
-
-             // uint32_t fl = nctohs(&packet[2]); //
-
-             // debug(1,"Sync Packet of %d bytes received: \"%s\", flags: %d, timestamps %u and
-        %u,
-        giving a latency of %d frames.",plen,obf,fl,rt,rtlt,rt-rtlt);
-             // debug(1,"Monotonic timestamps are: %" PRId64 " and %" PRId64 "
-        respectively.",monotonic_timestamp(rt, conn),monotonic_timestamp(rtlt, conn));
-           }
-      */
+        if (packet[1] == 0xd4) {                       // sync data
+                                                       /*
+                                                            // the following stanza is for debugging only -- normally commented out.
+                                                            {
+                                                              char obf[4096];
+                                                              char *obfp = obf;
+                                                              int obfc;
+                                                              for (obfc = 0; obfc < plen; obfc++) {
+                                                                snprintf(obfp, 3, "%02X", packet[obfc]);
+                                                                obfp += 2;
+                                                              };
+                                                              *obfp = 0;
+                                             
+                                             
+                                                              // get raw timestamp information
+                                                              // I think that a good way to understand these timestamps is that
+                                                              // (1) the rtlt below is the timestamp of the frame that should be playing at the
+                                                              // client-time specified in the packet if there was no delay
+                                                              // and (2) that the rt below is the timestamp of the frame that should be playing
+                                                              // at the client-time specified in the packet on this device taking account of
+                                                              // the delay
+                                                              // Thus, (3) the latency can be calculated by subtracting the second from the
+                                                              // first.
+                                                              // There must be more to it -- there something missing.
+                                             
+                                                              // In addition, it seems that if the value of the short represented by the second
+                                                              // pair of bytes in the packe is 7
+                                                              // then an extra time lag is expected to be added, presumably by
+                                                              // the AirPort Express.
+                                             
+                                                              // Best guess is that this delay is 11,025 frames.
+                                             
+                                                              // uint32_t rtlt = nctohl(&packet[4]); // raw timestamp less latency
+                                                              // uint32_t rt = nctohl(&packet[16]);  // raw timestamp
+                                             
+                                                              // uint32_t fl = nctohs(&packet[2]); //
+                                             
+                                                              // debug(1,"Sync Packet of %d bytes received: \"%s\", flags: %d, timestamps %u and
+                                                         %u,
+                                                         giving a latency of %d frames.",plen,obf,fl,rt,rtlt,rt-rtlt);
+                                                              // debug(1,"Monotonic timestamps are: %" PRId64 " and %" PRId64 "
+                                                         respectively.",monotonic_timestamp(rt, conn),monotonic_timestamp(rtlt, conn));
+                                                            }
+                                                       */
           if (conn->local_to_remote_time_difference) { // need a time packet to be interchanged
                                                        // first...
 
@@ -455,7 +455,7 @@ void *rtp_timing_sender(void *arg) {
     request_number++;
 
     if (request_number <= 4)
-      usleep(500000); //these are thread cancellation points
+      usleep(500000); // these are thread cancellation points
     else
       usleep(3000000);
   }
@@ -518,9 +518,9 @@ void *rtp_timing_receiver(void *arg) {
 
           return_time = arrival_time - conn->departure_time;
 
-          uint64_t rtus = (return_time * 1000000) >> 32;
+          //uint64_t rtus = (return_time * 1000000) >> 32;
 
-          if (rtus < 300000) {
+          if (((return_time * 1000000) >> 32) < 300000) {
 
             // debug(2,"Synchronisation ping return time is %f milliseconds.",(rtus*1.0)/1000);
 
@@ -683,7 +683,7 @@ void *rtp_timing_receiver(void *arg) {
             //(return_time*1000000)>>32);
           } else {
             debug(2, "Time ping turnaround time: %lld us -- it looks like a timing ping was lost.",
-                  rtus);
+                  (return_time * 1000000) >> 32);
           }
         } else {
           debug(1, "Timing port -- Unknown RTP packet of type 0x%02X length %d.", packet[1], nread);
@@ -947,8 +947,8 @@ void rtp_request_resend(seq_t first, uint32_t count, rtsp_conn_info *conn) {
                    (struct sockaddr *)&conn->rtp_client_control_socket, msgsize) == -1) {
           char em[1024];
           strerror_r(errno, em, sizeof(em));
-          debug(1,
-                "Error %d using send-to to an audio socket: \"%s\". Backing off for 1/16th of a second.",
+          debug(1, "Error %d using send-to to an audio socket: \"%s\". Backing off for 1/16th of a "
+                   "second.",
                 errno, em);
           conn->rtp_time_of_last_resend_request_error_fp = time_of_sending_fp;
         } else {
@@ -956,8 +956,10 @@ void rtp_request_resend(seq_t first, uint32_t count, rtsp_conn_info *conn) {
         }
 
       } else {
-        debug(3, "Dropping resend request packet to simulate a bad network. Backing off for 1/16th of a "
-                 "second.");
+        debug(
+            3,
+            "Dropping resend request packet to simulate a bad network. Backing off for 1/16th of a "
+            "second.");
         conn->rtp_time_of_last_resend_request_error_fp = time_of_sending_fp;
       }
     } else {