check that the clock is valid and reduce the Buffered Audio lead time to 0.25 seconds

This commit is contained in:
Mike Brady
2021-05-01 11:03:45 +01:00
parent 9a29fac7c7
commit 61b6b5934d
2 changed files with 17 additions and 8 deletions
+11 -5
View File
@@ -75,11 +75,17 @@ int ptp_get_clock_info(uint64_t *actual_clock_id, uint64_t *raw_offset) {
struct shm_structure nqptp_data;
if (get_nqptp_data(&nqptp_data) == 0) {
if (nqptp_data.version == NQPTP_SHM_STRUCTURES_VERSION) {
if (actual_clock_id != NULL)
*actual_clock_id = nqptp_data.master_clock_id;
if (raw_offset != NULL)
*raw_offset = nqptp_data.local_to_master_time_offset;
response = 0;
// assuming a clock id can not be zero
if (nqptp_data.master_clock_id != 0) {
if (actual_clock_id != NULL)
*actual_clock_id = nqptp_data.master_clock_id;
if (raw_offset != NULL)
*raw_offset = nqptp_data.local_to_master_time_offset;
response = 0;
} else {
debug(1,"clock not valid");
response = -2; // clock info not valid
}
} else {
if (failure_message_sent == 0) {
warn("This version of Shairport Sync requires an NQPTP with a Shared Memory Interface Version %u, but the installed version is %u. Please install the correct version of NQPTP.", NQPTP_SHM_STRUCTURES_VERSION, nqptp_data.version);
+6 -3
View File
@@ -1256,8 +1256,11 @@ int get_ptp_anchor_local_time_info(rtsp_conn_info *conn, uint32_t *anchorRTP,
} else if (ptp_status == -1) {
debug(3, "don't have the ptp clock interface");
response = -1;
} else if (ptp_status == -2) {
debug(1, "ptp clock not valid");
response = -1;
} else {
debug(3, "ptp clock not valid");
debug(3, "ptp clock error");
response = -1;
}
return response;
@@ -2040,7 +2043,7 @@ void *rtp_buffered_audio_processor(void *arg) {
// debug(1,"player buffer size and occupancy: %u and %u", player_buffer_size,
// player_buffer_occupancy);
if (player_buffer_occupancy >
((0.5 + 0.1) * 44100.0 / 352)) { // must be greater than the lead time.
((0.25 + 0.1) * 44100.0 / 352)) { // must be greater than the lead time.
// if there is enough stuff in the player's buffer, sleep for a while and try again
// debug(1,"sleep for 20 ms");
usleep(20000); // wait for a while
@@ -2064,7 +2067,7 @@ void *rtp_buffered_audio_processor(void *arg) {
int64_t lead_time = buffer_should_be_time - get_absolute_time_in_ns();
// debug(1,"lead time in buffered_audio is %f milliseconds.", lead_time * 0.000001);
// ask for 0.5 sec of leadtime
if ((lead_time >= (int64_t)(0.5 * 1000000000)) || (streaming_has_started == 1)) {
if ((lead_time >= (int64_t)(0.25 * 1000000000)) || (streaming_has_started == 1)) {
if (streaming_has_started == 0)
debug(1, "rtp lead time is %f ms.", 0.000001 * lead_time);
streaming_has_started = 1;