From 9d474e486aa2743c2c461da58005f71cb017a780 Mon Sep 17 00:00:00 2001 From: Andre Date: Sun, 25 Jun 2006 16:07:40 +0200 Subject: [PATCH] Don't exit if there are no more empty slots Though this is considered a serious error, it's not fatal. Just try again one second later. --- audiod.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/audiod.c b/audiod.c index 3b611196..ef830201 100644 --- a/audiod.c +++ b/audiod.c @@ -400,16 +400,18 @@ static void rn_event_handler(struct task *t) } } -static void open_receiver(int format) +static int open_receiver(int format) { struct audio_format_info *a = &afi[format]; struct slot_info *s; int ret, slot_num; struct receiver_node *rn; + const struct timeval restart_delay = {1, 0}; - slot_num = get_empty_slot(); - if (slot_num < 0) - clean_exit(EXIT_FAILURE, PARA_STRERROR(-slot_num)); + ret = get_empty_slot(); + if (ret < 0) + goto err; + slot_num = ret; s = &slot[slot_num]; s->format = format; s->receiver_node = para_calloc(sizeof(struct receiver_node)); @@ -418,11 +420,9 @@ static void open_receiver(int format) rn->conf = a->receiver_conf; ret = a->receiver->open(s->receiver_node); if (ret < 0) { - PARA_ERROR_LOG("failed to open receiver (%s)\n", - PARA_STRERROR(-ret)); free(s->receiver_node); s->receiver_node = NULL; - return; + goto err; } PARA_NOTICE_LOG("started %s: %s receiver in slot %d\n", audio_formats[s->format], a->receiver->name, slot_num); @@ -432,6 +432,11 @@ static void open_receiver(int format) rn->task.event_handler = rn_event_handler; sprintf(rn->task.status, "%s receiver node", rn->receiver->name); register_task(&rn->task); + return 1; +err: + PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret)); + tv_add(now, &restart_delay, &afi[format].restart_barrier); + return ret; } static int receiver_running(int format) @@ -463,8 +468,7 @@ static int open_current_receiver(struct sched *s) s->timeout = diff; return 0; } - open_receiver(i); - return 1; + return open_receiver(i) < 0? 0 : 1; } static void compute_time_diff(const struct timeval *status_time) -- 2.39.5