From 3c0957d110c506182edc29d507a8c84950512d25 Mon Sep 17 00:00:00 2001 From: philippe44 Date: Sat, 1 Feb 2020 23:21:59 -0800 Subject: [PATCH] AirPlay: retry NTP sync when initial RTT is >100ms - release --- components/raop/rtp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/components/raop/rtp.c b/components/raop/rtp.c index fbb9e2de..beccdda9 100644 --- a/components/raop/rtp.c +++ b/components/raop/rtp.c @@ -564,7 +564,7 @@ static void *rtp_thread_func(void *arg) { for (i = 0; i < 3; i++) { if (ctx->rtp_sockets[i].sock > sock) sock = ctx->rtp_sockets[i].sock; - // send synchro requets 3 times + // send synchro request 3 times ntp_sent = rtp_request_timing(ctx); } @@ -638,7 +638,9 @@ static void *rtp_thread_func(void *arg) { u16_t flags = ntohs(*(u16_t*)(pktp+2)); u32_t remote_gap = NTP2MS(remote - ctx->timing.remote); + // something is wrong and if we are supposed to be NTP synced, better ask for re-sync if (remote_gap > 10000) { + if (ctx->synchro.status & NTP_SYNC) rtp_request_timing(ctx); LOG_WARN("discarding remote timing information %u", remote_gap); break; } @@ -683,8 +685,9 @@ static void *rtp_thread_func(void *arg) { u64_t remote =(((u64_t) ntohl(*(u32_t*)(pktp+16))) << 32) + ntohl(*(u32_t*)(pktp+20)); u32_t roundtrip = gettime_ms() - reference; - // better discard sync packets when roundtrip is suspicious + // better discard sync packets when roundtrip is suspicious and ask for another one if (roundtrip > 100) { + rtp_request_timing(ctx); LOG_WARN("[%p]: discarding NTP roundtrip of %u ms", ctx, roundtrip); break; }