From 72ec8363472a01dfe107ffa87d15236f68dfe3fa Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Fri, 15 Jan 2010 21:41:06 +0100 Subject: [PATCH] audiod cleanups. It's pointless to change the scheduler's timeout during post_select(). --- audiod.c | 51 ++++++++++++++------------------------------------- 1 file changed, 14 insertions(+), 37 deletions(-) diff --git a/audiod.c b/audiod.c index 27eba9e3..e1d9cbb2 100644 --- a/audiod.c +++ b/audiod.c @@ -604,9 +604,8 @@ struct btr_node *audiod_get_btr_root(void) } /* returns slot num on success. */ -static int open_current_receiver(struct sched *s) +static int open_current_receiver(void) { - struct timeval diff; int ret, cafn = stat_task->current_audio_format_num; if (cafn < 0 || !stat_task->ct) @@ -615,27 +614,10 @@ static int open_current_receiver(struct sched *s) if (stat_task->vss_status != VSS_STATUS_FLAG_PLAYING) return -1; ret = receiver_running(cafn); - if (ret > 0) /* already running and not eof */ + if (ret != 0) /* already running */ return -1; - if (ret < 0) { /* eof */ - /* - * para_server uses a zero start time during the announcement - * period, i.e. before it sends the first chunk. Wait until - * this period begins to avoid restarting the receiver that - * belongs to the file just completed. - */ - if (stat_task->server_stream_start.tv_sec != 0) { - sched_request_timeout_ms(100, s); - return -1; - } - } - if (tv_diff(now, &afi[cafn].restart_barrier, &diff) < 0) { - if (tv_diff(&s->timeout, &diff, NULL) > 0) - sched_request_timeout(&diff, s); - else - sched_min_delay(s); + if (tv_diff(now, &afi[cafn].restart_barrier, NULL) < 0) return -1; - } /* start a new receiver */ return open_receiver(cafn); } @@ -1073,52 +1055,50 @@ static void set_stat_task_restart_barrier(unsigned seconds) tv_add(now, &delay, &stat_task->restart_barrier); } -static bool try_to_close_slot(int slot_num) +static void try_to_close_slot(int slot_num) { struct slot_info *s = &slot[slot_num]; struct audio_format_info *a = afi + s->format; int i; if (s->format < 0) - return false; + return; if (s->receiver_node && s->receiver_node->task.error != -E_TASK_UNREGISTERED) - return false; + return; for (i = 0; i < a->num_filters; i++) if (s->fns && s->fns[i].task.error != -E_TASK_UNREGISTERED) - return false; + return; if (a->num_writers > 0) { for (i = 0; i < a->num_writers; i++) if (s->wns && s->wns[i].task.error != -E_TASK_UNREGISTERED) - return false; + return; } else { if (s->wns && s->wns[0].task.error != -E_TASK_UNREGISTERED) - return false; + return; } PARA_INFO_LOG("closing slot %d\n", slot_num); close_writers(s); close_filters(s); close_receiver(slot_num); clear_slot(slot_num); - return true; } /* * Check if any receivers/filters/writers need to be started and do so if * necessary. */ -static void start_stop_decoders(struct sched *s) +static void start_stop_decoders(void) { int i, ret; struct slot_info *sl; struct audio_format_info *a; FOR_EACH_SLOT(i) - if (try_to_close_slot(i)) - sched_min_delay(s); + try_to_close_slot(i); if (audiod_status != AUDIOD_ON || !(stat_task->vss_status & VSS_STATUS_FLAG_PLAYING)) return kill_all_decoders(-E_NOT_PLAYING); - ret = open_current_receiver(s); + ret = open_current_receiver(); if (ret < 0) return; sl = slot + ret; @@ -1128,7 +1108,6 @@ static void start_stop_decoders(struct sched *s) open_writers(sl); activate_grab_clients(); btr_log_tree(sl->receiver_node->btrn, LL_NOTICE); - sched_min_delay(s); } static void status_pre_select(struct sched *s, struct task *t) @@ -1141,7 +1120,7 @@ static void status_pre_select(struct sched *s, struct task *t) } /* restart the client task if necessary */ -static void status_post_select(struct sched *s, struct task *t) +static void status_post_select(__a_unused struct sched *s, struct task *t) { struct status_task *st = container_of(t, struct status_task, task); @@ -1200,14 +1179,12 @@ static void status_post_select(struct sched *s, struct task *t) st->clock_diff_count--; client_open(argc, argv, &st->ct, NULL, NULL, st->btrn); set_stat_task_restart_barrier(2); - sched_min_delay(s); } else { char *argv[] = {"audiod", "--", "stat", "-p", NULL}; int argc = 4; client_open(argc, argv, &st->ct, NULL, NULL, st->btrn); set_stat_task_restart_barrier(5); - sched_min_delay(s); } free(stat_item_values[SI_BASENAME]); stat_item_values[SI_BASENAME] = para_strdup( @@ -1215,7 +1192,7 @@ static void status_post_select(struct sched *s, struct task *t) stat_client_write_item(SI_BASENAME); st->last_status_read = *now; out: - start_stop_decoders(s); + start_stop_decoders(); } static void init_status_task(struct status_task *st) -- 2.39.5