From: Andre Noll Date: Tue, 22 Dec 2015 22:28:46 +0000 (+0000) Subject: audiod: Avoid to report 100% time at startup. X-Git-Tag: v0.5.6~21^2~2 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=f23669d91a09066b7ecd7b07a74bea8fad61ad39 audiod: Avoid to report 100% time at startup. This teaches get_time_string() to handle the case of zero values for sss and wstime. These happen to be zero for a short time period when para_server is changing its audio file. --- diff --git a/audiod.c b/audiod.c index 8b9422bc..94afa1cf 100644 --- a/audiod.c +++ b/audiod.c @@ -309,7 +309,7 @@ static int get_play_time_slot_num(void) */ char *get_time_string(void) { - int ret, seconds = 0, length; + int ret, seconds = 0, length = stat_task->length_seconds; struct timeval *tmp, sum, sss, /* server stream start */ rstime, /* receiver start time */ wstime, /* writer start time */ @@ -321,8 +321,10 @@ char *get_time_string(void) if (audiod_status == AUDIOD_OFF) goto empty; - if (!(stat_task->vss_status & VSS_STATUS_FLAG_PLAYING)) { - if (stat_task->length_seconds) /* paused */ + if (stat_task->server_stream_start.tv_sec == 0) { + if (stat_task->vss_status & VSS_STATUS_FLAG_PLAYING) + goto out; /* server is about to change file */ + if (length > 0) /* paused */ return NULL; goto empty; /* stopped */ } @@ -331,7 +333,6 @@ char *get_time_string(void) * start. We use the slot info and fall back to the info from current * status items if no slot info is available. */ - length = stat_task->length_seconds; tmp = &stat_task->server_stream_start; if (s && s->wns && s->wns[0].btrn) { /* writer active in this slot */ btr_get_node_start(s->wns[0].btrn, &wstime); @@ -350,7 +351,7 @@ char *get_time_string(void) tv_diff(tmp, &stat_task->sa_time_diff, &sss); else tv_add(tmp, &stat_task->sa_time_diff, &sss); - if (!s || !s->wns || !s->wns[0].btrn) { + if (!s || !s->wns || !s->wns[0].btrn || wstime.tv_sec == 0) { struct timeval diff; tv_diff(now, &sss, &diff); seconds = diff.tv_sec + stat_task->offset_seconds;