From 054c845e9ac8ee3ab920d91e468eedb7cb1105ba Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Mon, 31 Mar 2008 13:15:37 +0200 Subject: [PATCH] audiod.c: Fix stat task restarting. --- audiod.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/audiod.c b/audiod.c index bde2b1e1..e33f7383 100644 --- a/audiod.c +++ b/audiod.c @@ -976,34 +976,18 @@ static void set_stat_task_restart_barrier(void) tv_add(now, &delay, &stat_task->restart_barrier); } -#if 0 -static void client_task_event_handler(__a_unused struct task *t) -{ - int i; - - if (t->ret == -E_HANDSHAKE_COMPLETE) - return; - unregister_task(t); - close_stat_pipe(); - if (t->ret != -E_SERVER_EOF) - stat_task->clock_diff_count = conf.clock_diff_count_arg; - set_stat_task_restart_barrier(); - FOR_EACH_AUDIO_FORMAT(i) - afi[i].restart_barrier = stat_task->restart_barrier; -} -#endif - +/* restart the client task if necessary */ static void status_pre_select(struct sched *s, struct task *t) { struct status_task *st = container_of(t, struct status_task, task); int ret; - if (st->ct || audiod_status == AUDIOD_OFF) + if (st->ct || audiod_status == AUDIOD_OFF) /* no need to restart */ return; if (!st->clock_diff_count && tv_diff(now, &st->restart_barrier, NULL) < 0) return; - if (st->clock_diff_count) { + if (st->clock_diff_count) { /* get status only one time */ char *argv[] = {"audiod", "stat", "1", NULL}; int argc = 3; if (tv_diff(now, &st->clock_diff_barrier, NULL) < 0) @@ -1030,10 +1014,12 @@ static void status_post_select(__a_unused struct sched *s, struct task *t) if (!st->ct || st->ct->status != CL_RECEIVING) return; - if (st->ct && audiod_status == AUDIOD_OFF) { - unregister_task(&st->ct->task); + if (audiod_status == AUDIOD_OFF || st->ct->task.error < 0) { + if (st->ct->task.error >= 0) + unregister_task(&st->ct->task); + if (audiod_status == AUDIOD_OFF) + st->clock_diff_count = conf.clock_diff_count_arg; close_stat_pipe(); - st->clock_diff_count = conf.clock_diff_count_arg; return; } bytes_left = for_each_line(st->ct->buf, st->ct->loaded, -- 2.39.5