From a6e02449fb3e2e44465a76eedadd9cd0593c698f Mon Sep 17 00:00:00 2001 From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Thu, 22 Sep 2022 16:25:57 +0100 Subject: [PATCH] Increase the RTSP idle timeout to ten seconds, and confine its operation to realtime and classic AirPlay only.: --- rtsp.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/rtsp.c b/rtsp.c index 8188425e..370d083d 100644 --- a/rtsp.c +++ b/rtsp.c @@ -1275,14 +1275,11 @@ void clear_ptp_clock() { ssize_t read_from_rtsp_connection(rtsp_conn_info *conn, void *buf, size_t count) { // first try to read with a timeout, to see if there is any traffic... - ssize_t response = timed_read_from_rtsp_connection(conn, 4000000000L, buf, count); + ssize_t response = timed_read_from_rtsp_connection(conn, 10000000000L, buf, count); if ((response == -1) && ((errno == EAGAIN) || (errno == EWOULDBLOCK))) { if (conn->rtsp_link_is_idle == 0) { debug(1, "Connection %d: RTSP connection is idle.", conn->connection_number); conn->rtsp_link_is_idle = 1; -#ifdef CONFIG_AIRPLAY_2 - clear_ptp_clock(); -#endif conn->udp_clock_sender_is_initialised = 0; conn->udp_clock_is_initialised = 0; } @@ -1291,15 +1288,22 @@ ssize_t read_from_rtsp_connection(rtsp_conn_info *conn, void *buf, size_t count) if (conn->rtsp_link_is_idle == 1) { conn->rtsp_link_is_idle = 0; debug(1, "Connection %d: RTSP connection traffic has resumed.", conn->connection_number); +#ifdef CONFIG_AIRPLAY_2 + if (conn->airplay_stream_type == realtime_stream) { + conn->last_anchor_info_is_valid = 0; + conn->anchor_remote_info_is_valid = 0; + conn->first_packet_timestamp = 0; + conn->input_frame_rate_starting_point_is_valid = 0; + ab_resync(conn); + } +#else + conn->last_anchor_info_is_valid = 0; conn->anchor_remote_info_is_valid = 0; conn->local_to_remote_time_difference_measurement_time = 0; conn->local_to_remote_time_difference = 0; conn->first_packet_timestamp = 0; conn->input_frame_rate_starting_point_is_valid = 0; ab_resync(conn); -#ifdef CONFIG_AIRPLAY_2 - conn->last_anchor_info_is_valid = 0; - set_client_as_ptp_clock(conn); #endif } return response;