Kill TASK_UNREGISTERED error code.
[paraslash.git] / audiod.c
index 039a688639a770ee40af0fd63c065d50cb324482..486a33ff5a26f9c5147e14a8c3eabd7c0246e816 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005-2010 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2005-2011 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
@@ -823,6 +823,14 @@ static int parse_receiver_args(void)
                ret = get_audio_format_num(arg);
                if (ret < 0)
                        goto out;
+               /*
+                * If multiple receivers are given for this audio format, the
+                * last one wins and we have to free the previous receiver
+                * config here. Since we are iterating backwards, the winning
+                * receiver arg is in fact the first one given.
+                */
+               if (afi[ret].receiver_conf)
+                       afi[ret].receiver->free_config(afi[ret].receiver_conf);
                afi[ret].receiver_conf = check_receiver_arg(recv_arg, &receiver_num);
                if (!afi[ret].receiver_conf) {
                        ret = -E_RECV_SYNTAX;
@@ -830,9 +838,9 @@ static int parse_receiver_args(void)
                }
                afi[ret].receiver = &receivers[receiver_num];
        }
-       /* use the first available receiver with no arguments
-        * for those audio formats for which no receiver
-        * was specified
+       /*
+        * Use the first available receiver with no arguments for those audio
+        * formats for which no receiver was specified.
         */
        cmd = para_strdup(receivers[0].name);
        FOR_EACH_AUDIO_FORMAT(i) {
@@ -1089,17 +1097,17 @@ static void try_to_close_slot(int slot_num)
 
        if (s->format < 0)
                return;
-       if (s->receiver_node && s->receiver_node->task.error != -E_TASK_UNREGISTERED)
+       if (s->receiver_node && s->receiver_node->task.error >= 0)
                return;
        for (i = 0; i < a->num_filters; i++)
-               if (s->fns && s->fns[i].task.error != -E_TASK_UNREGISTERED)
+               if (s->fns && s->fns[i].task.error >= 0)
                        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)
+                       if (s->wns && s->wns[i].task.error >= 0)
                                return;
        } else {
-               if (s->wns && s->wns[0].task.error != -E_TASK_UNREGISTERED)
+               if (s->wns && s->wns[0].task.error >= 0)
                        return;
        }
        PARA_INFO_LOG("closing slot %d\n", slot_num);
@@ -1180,7 +1188,7 @@ static void status_post_select(__a_unused struct sched *s, struct task *t)
                        kill_btrn(st->ct->btrn, &st->ct->task, -E_AUDIOD_OFF);
                        goto out;
                }
-               if (st->ct->task.error != -E_TASK_UNREGISTERED)
+               if (st->ct->task.error >= 0)
                        goto out;
                close_stat_pipe();
                st->clock_diff_count = conf.clock_diff_count_arg;
@@ -1191,7 +1199,7 @@ static void status_post_select(__a_unused struct sched *s, struct task *t)
                size_t sz;
                int ret;
                if (st->ct->task.error < 0) {
-                       if (st->ct->task.error != -E_TASK_UNREGISTERED)
+                       if (st->ct->task.error >= 0)
                                goto out;
                        close_stat_pipe();
                        goto out;