]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Improve the sync between AirPlay and movies like YouTube. Not sure we understand...
authorMike Brady <mikebrady@eircom.net>
Sun, 10 Dec 2017 22:26:19 +0000 (22:26 +0000)
committerMike Brady <mikebrady@eircom.net>
Sun, 10 Dec 2017 22:26:19 +0000 (22:26 +0000)
player.h
rtp.c
rtsp.c

index 6ee4f4d0565fa97c01d627ae95c83b0082e30556..3c9f43d0293c85b3e8f7c4d5b5926b26d29594b4 100644 (file)
--- a/player.h
+++ b/player.h
@@ -63,7 +63,7 @@ typedef struct {
 
 typedef struct {
   int connection_number; // for debug ID purposes, nothing else...
-
+  int64_t staticLatencyCorrection; // it seems iTunes needs some offset before it's more or less right. Odd.
 #if defined(HAVE_DBUS) || defined(HAVE_MPRIS)
   enum session_status_type play_state;
 #endif
diff --git a/rtp.c b/rtp.c
index 1e082bd1f3d5833cebb22f9ec16fabf3c2f49f40..22646d793386a1b608ff724e51eab4525f371699 100644 (file)
--- a/rtp.c
+++ b/rtp.c
@@ -227,10 +227,10 @@ void *rtp_control_receiver(void *arg) {
         sync_rtp_timestamp = monotonic_timestamp(ntohl(*((uint32_t *)&packet[16])), conn);
 
         if (config.use_negotiated_latencies) {
-          int64_t la = sync_rtp_timestamp - rtp_timestamp_less_latency + 11025;
+          int64_t la = sync_rtp_timestamp - rtp_timestamp_less_latency + conn->staticLatencyCorrection;
           if (la != config.latency) {
             config.latency = la;
-            // debug(1,"Using negotiated latency of %u frames.",config.latency);
+            debug(1,"Using negotiated latency of %lld frames and a static latency correction of %lld",sync_rtp_timestamp - rtp_timestamp_less_latency,conn->staticLatencyCorrection);
           }
         }
 
diff --git a/rtsp.c b/rtsp.c
index d32bc2662d4d576c6da3b164cc2c9507b008daad..41a5a85fab0f7fcb7900ccf5897d10a09d8ec564 100644 (file)
--- a/rtsp.c
+++ b/rtsp.c
@@ -765,11 +765,12 @@ static void handle_setup(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *
       else
         debug(2, "iTunes Version Number not found.");
       if (iTunesVersion >= 10) {
-        debug(2, "User-Agent is iTunes 10 or better, (actual version is %d); "
+        debug(1, "User-Agent is iTunes 10 or better, (actual version is %d); "
                  "selecting the iTunes "
                  "latency of %d frames.",
               iTunesVersion, config.iTunesLatency);
         config.latency = config.iTunesLatency;
+        conn->staticLatencyCorrection = 11025;
       }
     } else if (strstr(ua, "AirPlay") == ua) {
       debug(2, "User-Agent is AirPlay; selecting the AirPlay latency of %d frames.",
@@ -780,6 +781,7 @@ static void handle_setup(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *
                "of %d frames.",
             config.ForkedDaapdLatency);
       config.latency = config.ForkedDaapdLatency;
+      conn->staticLatencyCorrection = 11025;
     } else {
       debug(2, "Unrecognised User-Agent. Using latency of %d frames.", config.latency);
     }