From: Andre Noll Date: Thu, 8 Feb 2007 09:41:33 +0000 (+0100) Subject: don't set the initial_delay_barrier if time diff is unreliable X-Git-Tag: v0.2.15~28^2 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=566fce2b157e3cd134b35afc243472955423ea2c;p=paraslash.git don't set the initial_delay_barrier if time diff is unreliable --- diff --git a/audiod.c b/audiod.c index 9d0d0741..dbc1e850 100644 --- a/audiod.c +++ b/audiod.c @@ -467,14 +467,16 @@ static int open_current_receiver(struct sched *s) return open_receiver(i) < 0? 0 : 1; } -static void compute_time_diff(const struct timeval *status_time) +static unsigned compute_time_diff(const struct timeval *status_time) { struct timeval tmp, diff; - static int count; + static unsigned count; int sign, sa_time_diff_sign = stat_task->sa_time_diff_sign; const struct timeval max_deviation = {0, 500 * 1000}; const int time_smooth = 5; + if (!status_time) + return count; sign = tv_diff(status_time, now, &diff); // PARA_NOTICE_LOG("%s: sign = %i, sa_time_diff_sign = %i\n", __func__, // sign, sa_time_diff_sign); @@ -504,6 +506,7 @@ static void compute_time_diff(const struct timeval *status_time) ); out: stat_task->sa_time_diff_sign = sa_time_diff_sign; + return count; } static void check_stat_line(char *line) @@ -546,13 +549,15 @@ static void check_stat_line(char *line) delay.tv_usec = (conf.stream_delay_arg % 1000) * 1000; stat_task->server_stream_start.tv_sec = sec; stat_task->server_stream_start.tv_usec = usec; - if (stat_task->sa_time_diff_sign < 0) - tv_add(&stat_task->server_stream_start, - &stat_task->sa_time_diff, &a_start); - else - tv_diff(&stat_task->server_stream_start, - &stat_task->sa_time_diff, &a_start); - tv_add(&a_start, &delay, &initial_delay_barrier); + if (compute_time_diff(NULL) > 2) { + if (stat_task->sa_time_diff_sign < 0) + tv_add(&stat_task->server_stream_start, + &stat_task->sa_time_diff, &a_start); + else + tv_diff(&stat_task->server_stream_start, + &stat_task->sa_time_diff, &a_start); + tv_add(&a_start, &delay, &initial_delay_barrier); + } } break; case SI_CURRENT_TIME: