From dd57999338292ecf28060b70137f980b8f307b34 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Mon, 11 Jan 2010 02:51:08 +0100 Subject: [PATCH] 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. --- audiod.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) 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 */ -- 2.39.2