BT & AirPlay switch fix - release

This commit is contained in:
philippe44
2019-11-24 15:37:34 -08:00
parent 64b8040b30
commit 131769ff4d
3 changed files with 10 additions and 3 deletions

View File

@@ -637,6 +637,12 @@ static void *rtp_thread_func(void *arg) {
// sync packet
case 0x54: {
u32_t rtp_now_latency = ntohl(*(u32_t*)(pktp+4));
u64_t remote = (((u64_t) ntohl(*(u32_t*)(pktp+8))) << 32) + ntohl(*(u32_t*)(pktp+12));
u32_t rtp_now = ntohl(*(u32_t*)(pktp+16));
u16_t flags = ntohs(*(u16_t*)(pktp+2));
u32_t remote_gap = NTP2MS(remote - ctx->timing.remote);
if (remote_gap > 10000) {
LOG_WARN("discarding remote timing information %u", remote_gap);
break;
}
@@ -646,7 +652,7 @@ static void *rtp_thread_func(void *arg) {
// re-align timestamp and expected local playback time (and magic 11025 latency)
ctx->latency = rtp_now - rtp_now_latency;
if (flags == 7 || flags == 4) ctx->latency += 11025;
if (ctx->latency < MIN_LATENCY) ctx->latency = MIN_LATENCY;
if (ctx->latency < MIN_LATENCY) ctx->latency = MIN_LATENCY;
else if (ctx->latency > MAX_LATENCY) ctx->latency = MAX_LATENCY;
ctx->synchro.rtp = rtp_now - ctx->latency;
ctx->synchro.time = ctx->timing.local + remote_gap;