From: Mike Brady Date: Sun, 10 Dec 2017 22:26:19 +0000 (+0000) Subject: Improve the sync between AirPlay and movies like YouTube. Not sure we understand... X-Git-Tag: 3.1.5~3^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=86f76ad6ce9291ebd95321c1b40f023c2e822fad;p=thirdparty%2Fshairport-sync.git Improve the sync between AirPlay and movies like YouTube. Not sure we understand the negotiation for syncing. --- diff --git a/player.h b/player.h index 6ee4f4d0..3c9f43d0 100644 --- 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 1e082bd1..22646d79 100644 --- 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 d32bc266..41a5a85f 100644 --- 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); }