NEWS,md: Add introductory text for v0.5.7.
[paraslash.git] / audioc.c
index fe7165edd966d1afeaf46c15c252fa70c229e2c6..f8fd80faa77bdea4a4f1139bb8168268ce59ddc3 100644 (file)
--- a/audioc.c
+++ b/audioc.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005-2014 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2005 Andre Noll <maan@tuebingen.mpg.de>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
@@ -13,7 +13,6 @@
 #include <arpa/inet.h>
 #include <sys/un.h>
 #include <netdb.h>
-#include <stdbool.h>
 #include <signal.h>
 
 #include "audioc.cmdline.h"
@@ -25,7 +24,8 @@
 #include "ggo.h"
 #include "version.h"
 
-INIT_AUDIOC_ERRLISTS;
+/** Array of error strings. */
+DEFINE_PARA_ERRLIST;
 
 /** The gengetopt structure containing command line args. */
 static struct audioc_args_info conf;
@@ -72,14 +72,14 @@ fail:
 #include "sched.h"
 #include "buffer_tree.h"
 #include "interactive.h"
-#include "audiod_completion.h"
+#include "audiod.completion.h"
 
 static struct sched sched;
 
 struct audioc_task {
        int fd;
        struct btr_node *btrn;
-       struct task task;
+       struct task *task;
 };
 
 static struct i9e_completer audiod_completers[];
@@ -130,9 +130,9 @@ static struct i9e_completer audiod_completers[] = {
        {.name = NULL}
 };
 
-static void audioc_pre_select(struct sched *s, struct task *t)
+static void audioc_pre_select(struct sched *s, void *context)
 {
-       struct audioc_task *at = container_of(t, struct audioc_task, task);
+       struct audioc_task *at = context;
        int ret = btr_node_status(at->btrn, 0, BTR_NT_ROOT);
 
        if (ret < 0)
@@ -140,10 +140,10 @@ static void audioc_pre_select(struct sched *s, struct task *t)
        para_fd_set(at->fd, &s->rfds, &s->max_fileno);
 }
 
-static int audioc_post_select(struct sched *s, struct task *t)
+static int audioc_post_select(struct sched *s, void *context)
 {
        char *buf = NULL;
-       struct audioc_task *at = container_of(t, struct audioc_task, task);
+       struct audioc_task *at = context;
        int ret = btr_node_status(at->btrn, 0, BTR_NT_ROOT);
 
        if (ret < 0)
@@ -168,13 +168,7 @@ out:
        return ret;
 }
 
-static struct audioc_task audioc_task = {
-       .task = {
-               .pre_select = audioc_pre_select,
-               .post_select = audioc_post_select,
-               .status = "audioc task"
-       },
-}, *at = &audioc_task;
+static struct audioc_task audioc_task, *at = &audioc_task;
 
 static int audioc_i9e_line_handler(char *line)
 {
@@ -202,8 +196,12 @@ static int audioc_i9e_line_handler(char *line)
        args = NULL;
        at->btrn = btr_new_node(&(struct btr_node_description)
                EMBRACE(.name = "audioc line handler"));
-       at->task.error = 0;
-       register_task(&sched, &at->task);
+       at->task = task_register(&(struct task_info) {
+               .name = "audioc",
+               .pre_select = audioc_pre_select,
+               .post_select = audioc_post_select,
+               .context = at,
+       }, &sched);
        i9e_attach_to_stdout(at->btrn);
        return 1;
 close:
@@ -248,6 +246,7 @@ __noreturn static void interactive_session(void)
                goto out;
        para_log = i9e_log;
        ret = schedule(&sched);
+       sched_shutdown(&sched);
        i9e_close();
        para_log = stderr_log;
 out: