From: Mike Brady Date: Wed, 10 Jan 2018 13:02:52 +0000 (+0000) Subject: Only allow sync packets after flush or resume to set latency and set an initial defau... X-Git-Tag: 3.2d29~127^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3c08cedb780c581033235dc688eb7f1fdeebaf13;p=thirdparty%2Fshairport-sync.git Only allow sync packets after flush or resume to set latency and set an initial default latency. --- diff --git a/player.c b/player.c index f37be4b9..27520753 100644 --- a/player.c +++ b/player.c @@ -1374,6 +1374,11 @@ static void *player_thread_func(void *arg) { conn->first_packet_timestamp = 0; conn->flush_requested = 0; // conn->fix_volume = 0x10000; + + if (conn->latency==0) { + debug(1,"No latency has (yet) been specified. Setting 99225 (2.25 seconds) frames as a default."); + conn->latency = 99225; + } int rc = pthread_mutex_init(&conn->ab_mutex, NULL); if (rc) diff --git a/rtp.c b/rtp.c index 7fc1a035..2a24abc3 100644 --- a/rtp.c +++ b/rtp.c @@ -182,7 +182,7 @@ void *rtp_control_receiver(void *arg) { uint8_t packet[2048], *pktp; struct timespec tn; uint64_t remote_time_of_sync, local_time_now, remote_time_now; - int64_t sync_rtp_timestamp, rtp_timestamp_less_latency; + int64_t sync_rtp_timestamp; ssize_t nread; while (conn->please_stop == 0) { fd_set readfds; @@ -223,7 +223,6 @@ void *rtp_control_receiver(void *arg) { // debug(1,"Remote Sync Time: %0llx.",remote_time_of_sync); - rtp_timestamp_less_latency = monotonic_timestamp(ntohl(*((uint32_t *)&packet[4])), conn); sync_rtp_timestamp = monotonic_timestamp(ntohl(*((uint32_t *)&packet[16])), conn); if (config.userSuppliedLatency) { @@ -231,7 +230,8 @@ void *rtp_control_receiver(void *arg) { debug(1,"Using the user-supplied latency: %lld.",config.userSuppliedLatency); } conn->latency = config.userSuppliedLatency; - } else { + } else if (packet[0] & 0x10) { // only set latency if it's a packet just after a flush or resume + int64_t rtp_timestamp_less_latency = monotonic_timestamp(ntohl(*((uint32_t *)&packet[4])), conn); int64_t la = sync_rtp_timestamp - rtp_timestamp_less_latency + config.fixedLatencyOffset; if ((conn->maximum_latency) && (conn->maximum_latency