]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Initial debug and exploratory code
authorMike Brady <mikebrady@eircom.net>
Fri, 25 Sep 2015 15:47:58 +0000 (16:47 +0100)
committerMike Brady <mikebrady@eircom.net>
Fri, 25 Sep 2015 15:47:58 +0000 (16:47 +0100)
player.c
rtp.c
rtsp.c

index c86b9724c809506152656469701d48a04c3d1c36..859e5136ebf5a4b98b746cd626c6cde4d4e91895 100644 (file)
--- a/player.c
+++ b/player.c
@@ -299,7 +299,11 @@ void player_put_packet(seq_t seqno, uint32_t timestamp, uint8_t *data, int len)
   time_of_last_audio_packet = get_absolute_time_in_fp();
   if (connection_state_to_output) { // if we are supposed to be processing these packets
 
-    if ((flush_rtp_timestamp != 0) &&
+    if (flush_rtp_timestamp != 0)
+       debug(1,"Flush_rtp_timestamp is %u",flush_rtp_timestamp);
+
+//    if ((flush_rtp_timestamp != 0) &&
+    if ((0) &&
         ((timestamp == flush_rtp_timestamp) || seq32_order(timestamp, flush_rtp_timestamp))) {
       debug(2, "Dropping flushed packet in player_put_packet, seqno %u, timestamp %u, flushing to "
                "timestamp: %u.",
@@ -1243,7 +1247,7 @@ void player_volume(double f) {
 }
 
 void player_flush(uint32_t timestamp) {
-  // debug(1,"Flush requested up to %u. It seems as if 0 is special.",timestamp);
+  debug(1,"Flush requested up to %u. It seems as if 0 is special.",timestamp);
   pthread_mutex_lock(&flush_mutex);
   flush_requested = 1;
   // if (timestamp!=0)
diff --git a/rtp.c b/rtp.c
index e00a7536a610b657bb5877aecd4a3ead704848c4..2053f43c686b65f39dea8064a802d8b5a74f205c 100644 (file)
--- a/rtp.c
+++ b/rtp.c
@@ -193,6 +193,8 @@ static void *rtp_control_receiver(void *arg) {
 
         rtp_timestamp_less_latency = ntohl(*((uint32_t *)&packet[4]));
         sync_rtp_timestamp = ntohl(*((uint32_t *)&packet[16]));
+        
+        debug(1,"Latency is %u frames.",sync_rtp_timestamp-rtp_timestamp_less_latency);
 
         if (packet[0] & 0x10) {
           // if it's a packet right after a flush or resume
diff --git a/rtsp.c b/rtsp.c
index cbd1fa6fa3bc2ecd5d3e2780118af8426b86ede3..068b12f15f7a12b3bf31876131badeeeec3fc956 100644 (file)
--- a/rtsp.c
+++ b/rtsp.c
@@ -584,6 +584,12 @@ static void msg_write_response(int fd, rtsp_message *resp) {
 static void handle_record(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp) {
   debug(1,"Handle Record");
   resp->respcode = 200;
+   // I think this is for telling the client what the asbsolute minimum latency actually is,
+   // and when the client specifies a latency, it should be added to this figure.
+   
+   // Thus, AirPlay's latency figure of 77175, when added to 11025 gives you exactly 88200
+   // and iTunes' latency figure of 88553, when added to 11025 gives you 99578, pretty close to the 99400 we guessed.
+   
   msg_add_header(resp, "Audio-Latency", "88200");
   
   char *p;
@@ -596,13 +602,14 @@ static void handle_record(rtsp_conn_info *conn, rtsp_message *req, rtsp_message
     p = strstr(hdr, "rtptime=");
     if (p) {
       p = strchr(p, '=') + 1;
-      if (p)
+      if (p) {
         rtptime = uatoi(p); // unsigned integer -- up to 2^32-1
+                               rtptime--;
+                               // debug(1,"RTSP Flush Requested by handle_record: %u.",rtptime);
+                               player_flush(rtptime);
+      }
     }
   }
-  rtptime--;
-  debug(1,"RTSP Flush Requested by handle_record: %u.",rtptime);
-  player_flush(rtptime);
 }
 
 static void handle_options(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp) {