From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Thu, 13 May 2021 19:12:12 +0000 (+0100) Subject: If a PTP clock isn't available, use existing timing data if it's still valid. X-Git-Tag: 4.0-dev~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2180c7147f0170001d3c35a98d793bd078004525;p=thirdparty%2Fshairport-sync.git If a PTP clock isn't available, use existing timing data if it's still valid. --- diff --git a/rtp.c b/rtp.c index 2dd5f185..ab85cc09 100644 --- a/rtp.c +++ b/rtp.c @@ -1274,7 +1274,7 @@ int get_ptp_anchor_local_time_info(rtsp_conn_info *conn, uint32_t *anchorRTP, if ((clock_status_t)response != conn->clock_status) { switch (response) { case clock_ok: - debug(1, "Connection %d: NQPTP clock is valid and available.", conn->connection_number); + debug(1, "Connection %d: NQPTP clock % " PRIx64 " on line.", conn->connection_number, actual_clock_id); break; case clock_service_unavailable: debug(1, "Connection %d: NQPTP clock is not available.", conn->connection_number); @@ -1311,6 +1311,14 @@ int get_ptp_anchor_local_time_info(rtsp_conn_info *conn, uint32_t *anchorRTP, } conn->clock_status = response; } + + if ((response != clock_ok) && (conn->last_anchor_info_is_valid != 0)) { + if (anchorRTP != NULL) + *anchorRTP = conn->anchor_rtptime; + if (anchorLocalTime != NULL) + *anchorLocalTime = conn->anchor_time - conn->last_anchor_clock_offset; + response = clock_ok; + } return response; }