audiod: Properly handle wng open failures.
authorAndre Noll <maan@systemlinux.org>
Sun, 10 May 2009 12:11:38 +0000 (14:11 +0200)
committerAndre Noll <maan@systemlinux.org>
Sun, 10 May 2009 12:11:38 +0000 (14:11 +0200)
If opening the writer node group fails, no task is being registered to the
scheduler although a task structure is allocated. This makes audiod think
everything is fine until the output buffer of the receiver or a filter is
filled up which may take several seconds.

Fix this flaw by setting the error field of the wng to -E_TASK_UNREGISTERED.
This causes audiod to close the receiver node and the filter chain and to
clear the affected slot.

audiod.c
write_common.c

index 7781965..ce5bc55 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -437,10 +437,8 @@ static void open_writers(int slot_num)
                s->wng->writer_nodes[i].writer = a->writers[i];
        }
        ret = wng_open(s->wng);
-       if (ret < 0) {
-               PARA_ERROR_LOG("%s\n", para_strerror(-ret));
+       if (ret < 0)
                return;
-       }
        s->wstime = *now;
        s->server_stream_start = stat_task->server_stream_start.tv_sec?
                stat_task->server_stream_start : *now;
index b684661..4619d40 100644 (file)
@@ -99,7 +99,9 @@ err_out:
                struct writer_node *wn = &g->writer_nodes[--i];
                wn->writer->close(wn);
        }
+       free(g->writer_nodes);
        g->num_writers = 0;
+       g->task.error = -E_TASK_UNREGISTERED;
        return ret;
 }