From: Andre Noll Date: Sat, 4 Jun 2016 17:39:01 +0000 (+0200) Subject: Merge branch 'refs/heads/t/audiod-time-string' X-Git-Tag: v0.5.6~21 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=ef9c3e5f615987120b8c6d51f64e49176ddb176f;hp=046359b034b67972a2a9d91cfd40476bb15f5785 Merge branch 'refs/heads/t/audiod-time-string' Was cooking for several months. * refs/heads/t/audiod-time-string: audiod: Improve get_time_string(). audiod: Force status dump on slot changes. audiod: Avoid to report 100% time at startup. audiod: Simplify get_time_string() --- diff --git a/NEWS.md b/NEWS.md index a0bec53c..b95cbb4f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -21,6 +21,7 @@ not mentioned here have accumulated and are also part of the release. - The manual and this NEWS file have been converted to markdown. - Cleanup of the wma decoder and bitstream code. - Improved wide-character support and fixes related to signal handling. +- para_gui no longer reports 100% playing time at the stream start. Download: [tarball](./releases/paraslash-git.tar.bz2) diff --git a/audiod.c b/audiod.c index 798142f3..5909859b 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,19 +321,18 @@ 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 */ } - if (audiod_status == AUDIOD_ON && !s) - goto empty; /* * 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 && s->wns[0].btrn) { /* writer active in this slot */ btr_get_node_start(s->wns[0].btrn, &wstime); @@ -352,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; @@ -364,7 +363,8 @@ char *get_time_string(void) if (s->receiver_node->btrn) { btr_get_node_start(s->receiver_node->btrn, &rstime); ret = tv_diff(&rstime, &sss, &rskip); - if (ret > 0) { /* audiod was started in the middle of the stream */ + if (ret > 0 && rskip.tv_sec > 2) { + /* audiod was started in the middle of the stream */ tv_add(&wtime, &rskip, &sum); seconds += sum.tv_sec; } else @@ -1230,10 +1230,15 @@ static void close_slot(int slot_num) static void close_unused_slots(void) { int i; + bool dump = false; FOR_EACH_SLOT(i) - if (must_close_slot(i)) + if (must_close_slot(i)) { close_slot(i); + dump = true; + } + if (dump) + audiod_status_dump(true); } /* @@ -1278,6 +1283,7 @@ static void start_stop_decoders(void) open_writers(sl); activate_grab_clients(&sched); btr_log_tree(sl->receiver_node->btrn, LL_NOTICE); + audiod_status_dump(true); } static void status_pre_select(struct sched *s, void *context)