]> git.tue.mpg.de Git - paraslash.git/commitdiff
Don't exit if there are no more empty slots
authorAndre <maan@p133.(none)>
Sun, 25 Jun 2006 14:07:40 +0000 (16:07 +0200)
committerAndre <maan@p133.(none)>
Sun, 25 Jun 2006 14:07:40 +0000 (16:07 +0200)
Though this is considered a serious error, it's not fatal. Just try
again one second later.

audiod.c

index 3b6111964a8012de6bbdddd4b7ec340a1173ce48..ef83020186addb8f1825ececf7821413d253b8d5 100644 (file)
--- 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)