diff --git a/RELEASENOTES-DEVELOPMENT.md b/RELEASENOTES-DEVELOPMENT.md index e845aa33..c91f6307 100644 --- a/RELEASENOTES-DEVELOPMENT.md +++ b/RELEASENOTES-DEVELOPMENT.md @@ -1,3 +1,7 @@ +Version-4.1-dev-115-g8656149d +==== +* Simplify and improve timing when a play session from a new device is started. + Version-4.1-dev-106-ge98111fb ==== #### Enhancement diff --git a/player.c b/player.c index 1feee08f..2e9819c9 100644 --- a/player.c +++ b/player.c @@ -1062,17 +1062,23 @@ static abuf_t *buffer_get_frame(rtsp_conn_info *conn) { conn->first_packet_time_to_play = should_be_time; int64_t lt = conn->first_packet_time_to_play - local_time_now; - - if (lt < 100000000) - debug(1, "Connection %d: Short lead time for first frame %" PRId64 ": %f seconds.", - conn->connection_number, conn->first_packet_timestamp, lt * 0.000000001); + if (lt < 150000000) { + debug(1, "Connection %d: Short lead time for first frame %" PRId64 ": %f seconds. Flushing 0.5 seconds", + conn->connection_number, conn->first_packet_timestamp, lt * 0.000000001); + do_flush(conn->first_packet_timestamp + 5 * 4410, conn); + } else { + debug(1, "Connection %d: Lead time for first frame %" PRId64 ": %f seconds.", + conn->connection_number, conn->first_packet_timestamp, lt * 0.000000001); + } +/* int64_t lateness = local_time_now - conn->first_packet_time_to_play; if (lateness > 0) { debug(1, "First packet is %" PRId64 " nanoseconds late! Flushing 0.5 seconds", lateness); - do_flush(conn->first_packet_timestamp + 5 * 4410, conn); + } +*/ } if (conn->first_packet_time_to_play != 0) { diff --git a/rtp.c b/rtp.c index 4bd07a60..348ac869 100644 --- a/rtp.c +++ b/rtp.c @@ -1280,7 +1280,7 @@ int get_ptp_anchor_local_time_info(rtsp_conn_info *conn, uint32_t *anchorRTP, if (response == clock_ok) { uint64_t time_now = get_absolute_time_in_ns(); int64_t time_since_sample = time_now - actual_time_of_sample; - if (time_since_sample > 10000000000) { + if (time_since_sample > 300000000000) { if (long_time_notifcation_done == 0) { debug(1, "The last PTP timing sample is pretty old: %f seconds.", 0.000000001 * time_since_sample); @@ -1305,7 +1305,7 @@ int get_ptp_anchor_local_time_info(rtsp_conn_info *conn, uint32_t *anchorRTP, // if the master clock and the anchor clock are the same // wait at least this time before using the new master clock // note that mastershipo may be backdated - if (duration_of_mastership < 2000000000) { + if (duration_of_mastership < 1500000000) { debug(3, "master not old enough yet: %f ms", 0.000001 * duration_of_mastership); response = clock_not_ready; } else if ((duration_of_mastership > 5000000000) || diff --git a/rtsp.c b/rtsp.c index 6b46310a..cd76c537 100644 --- a/rtsp.c +++ b/rtsp.c @@ -2538,7 +2538,7 @@ void handle_teardown_2(rtsp_conn_info *conn, __attribute__((unused)) rtsp_messag resp->respcode = 451; // don't know what to do here } // debug(1,"Bogus exit for valgrind -- remember to comment it out!."); - // exit(EXIT_SUCCESS); // + // exit(EXIT_SUCCESS); // } #endif @@ -2679,6 +2679,7 @@ void handle_setup_2(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp) // if it's a full service PTP stream, we get groupUUID, groupContainsGroupLeader and // timingPeerList if (conn->airplay_stream_category == ptp_stream) { + ptp_send_control_message_string("T"); // remove all previous history debug_log_rtsp_message(2, "SETUP \"PTP\" message", req); plist_t groupUUID = plist_dict_get_item(messagePlist, "groupUUID"); if (groupUUID) { @@ -2836,8 +2837,8 @@ void handle_setup_2(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp) debug(2, "Connection %d: SETUP mdns_update on %s.", conn->connection_number, get_category_string(conn->airplay_stream_category)); mdns_update(NULL, secondary_txt_records); - - + + resp->respcode = 200; } else {