diff --git a/common.h b/common.h index b0448e64..6b38442d 100644 --- a/common.h +++ b/common.h @@ -120,6 +120,8 @@ uint32_t uatoi(const char *nptr); shairport_cfg config; config_t config_file_stuff; +int64_t session_corrections; + void command_start(void); void command_stop(void); diff --git a/player.c b/player.c index 3ae9bac7..47f9b27c 100644 --- a/player.c +++ b/player.c @@ -855,6 +855,7 @@ typedef struct stats { // statistics for running averages } stats_t; static void *player_thread_func(void *arg) { + session_corrections = 0; // check that there are enough buffers to accommodate the desired latency and the latency offset int maximum_latency = config.latency+config.audio_backend_latency_offset; @@ -1115,11 +1116,14 @@ static void *player_thread_func(void *arg) { tsum_of_sync_errors += sync_error; tsum_of_drifts += statistics[newest_statistic].drift; - if (amount_to_stuff > 0) + if (amount_to_stuff > 0) { tsum_of_insertions_and_deletions += amount_to_stuff; - else + } else { tsum_of_insertions_and_deletions -= amount_to_stuff; + } tsum_of_corrections += amount_to_stuff; + session_corrections += amount_to_stuff; + newest_statistic = (newest_statistic + 1) % trend_interval; number_of_statistics++; diff --git a/rtp.c b/rtp.c index 8de54534..d6a0eab7 100644 --- a/rtp.c +++ b/rtp.c @@ -406,15 +406,21 @@ static void *rtp_timing_receiver(void *arg) { } uint64_t clock_drift; + int64_t current_delay; +// if (config.output->delay) { +// current_delay = config.output->delay(); +// } if (first_local_to_remote_time_difference>=local_to_remote_time_difference) { clock_drift = ((first_local_to_remote_time_difference - local_to_remote_time_difference) * 1000000)>>32; - debug(1, "-%llu", clock_drift); +// debug(1, "-%llu\t%lld\t%lld", clock_drift,(session_corrections*1000000)/44100,current_delay); + debug(1, "-%llu\t%lld", clock_drift,(session_corrections*1000000)/44100); //debug(1,"Clock drift is -%lld usec.",clock_drift); } else { clock_drift = ((local_to_remote_time_difference - first_local_to_remote_time_difference) * 1000000) >>32; //debug(1,"Clock drift is %lld usec.",clock_drift); - debug(1, "%llu", clock_drift); +// debug(1, "%llu\t%lld\t%lld", clock_drift,(session_corrections*1000000)/44100,current_delay); + debug(1, "%llu\t%lld\t", clock_drift,(session_corrections*1000000)/44100); } } else {