From: Andre Noll Date: Mon, 11 Jan 2010 01:51:08 +0000 (+0100) Subject: audiod: Fix time string. X-Git-Tag: v0.4.2~160 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=dd57999338292ecf28060b70137f980b8f307b34;hp=decf72f578ef0cb7a3bc3a81834ef64c2b19c91f audiod: Fix time string. Copy the data which is relevant for generating the string at writer node start time, i.e. when the writer produced its first output. --- diff --git a/audiod.c b/audiod.c index a6408d87..456813b1 100644 --- a/audiod.c +++ b/audiod.c @@ -196,13 +196,25 @@ char *get_time_string(int slot_num) } if (audiod_status == AUDIOD_ON && !s) goto empty; - /* valid status items and playing */ + /* + * Valid status items and playing, set length and tmp to the stream + * 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) { /* writer active in this slot */ - length = s->seconds_total; - tmp = &s->server_stream_start; - } else { /* standby mode, rely on status items */ - length = stat_task->length_seconds; - tmp = &stat_task->server_stream_start; + btr_get_node_start(s->wns[0].btrn, &wstime); + if (wstime.tv_sec != 0) { /* writer wrote something */ + if (s->server_stream_start.tv_sec == 0) { + /* copy status info to slot */ + s->server_stream_start = stat_task->server_stream_start; + s->offset_seconds = stat_task->offset_seconds; + s->seconds_total = stat_task->length_seconds; + } + length = s->seconds_total; + tmp = &s->server_stream_start; + } } if (stat_task->sa_time_diff_sign > 0) tv_diff(tmp, &stat_task->sa_time_diff, &sss); @@ -214,7 +226,6 @@ char *get_time_string(int slot_num) seconds = diff.tv_sec + stat_task->offset_seconds; goto out; } - btr_get_node_start(s->wns[0].btrn, &wstime); tv_diff(now, &wstime, &wtime); //PARA_CRIT_LOG("offset %d\n", s->offset_seconds); seconds = s->offset_seconds; @@ -476,10 +487,6 @@ static void open_writers(struct slot_info *s) register_writer_node(wn, parent); } } - s->server_stream_start = stat_task->server_stream_start.tv_sec? - stat_task->server_stream_start : *now; - s->offset_seconds = stat_task->offset_seconds; - s->seconds_total = stat_task->length_seconds; } /* returns slot num on success */