]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
task_register() conversion: audioc task
authorAndre Noll <maan@systemlinux.org>
Mon, 30 Dec 2013 22:23:31 +0000 (22:23 +0000)
committerAndre Noll <maan@systemlinux.org>
Sun, 25 May 2014 13:36:37 +0000 (15:36 +0200)
audioc.c

index 5f6b5ae1195645e3a8b4c2b458559625a036701c..ab7253f698946c44651325611141ec34ffeb66e1 100644 (file)
--- a/audioc.c
+++ b/audioc.c
@@ -79,7 +79,7 @@ static struct sched sched;
 struct audioc_task {
        int fd;
        struct btr_node *btrn;
 struct audioc_task {
        int fd;
        struct btr_node *btrn;
-       struct task task;
+       struct task *task;
 };
 
 static struct i9e_completer audiod_completers[];
 };
 
 static struct i9e_completer audiod_completers[];
@@ -123,7 +123,7 @@ static struct i9e_completer audiod_completers[] = {
 
 static void audioc_pre_select(struct sched *s, struct task *t)
 {
 
 static void audioc_pre_select(struct sched *s, struct task *t)
 {
-       struct audioc_task *at = container_of(t, struct audioc_task, task);
+       struct audioc_task *at = task_context(t);
        int ret = btr_node_status(at->btrn, 0, BTR_NT_ROOT);
 
        if (ret < 0)
        int ret = btr_node_status(at->btrn, 0, BTR_NT_ROOT);
 
        if (ret < 0)
@@ -134,7 +134,7 @@ static void audioc_pre_select(struct sched *s, struct task *t)
 static int audioc_post_select(struct sched *s, struct task *t)
 {
        char *buf = NULL;
 static int audioc_post_select(struct sched *s, struct task *t)
 {
        char *buf = NULL;
-       struct audioc_task *at = container_of(t, struct audioc_task, task);
+       struct audioc_task *at = task_context(t);
        int ret = btr_node_status(at->btrn, 0, BTR_NT_ROOT);
 
        if (ret < 0)
        int ret = btr_node_status(at->btrn, 0, BTR_NT_ROOT);
 
        if (ret < 0)
@@ -159,13 +159,7 @@ out:
        return ret;
 }
 
        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)
 {
 
 static int audioc_i9e_line_handler(char *line)
 {
@@ -193,8 +187,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"));
        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:
        i9e_attach_to_stdout(at->btrn);
        return 1;
 close:
@@ -239,6 +237,7 @@ __noreturn static void interactive_session(void)
                goto out;
        para_log = i9e_log;
        ret = schedule(&sched);
                goto out;
        para_log = i9e_log;
        ret = schedule(&sched);
+       sched_shutdown(&sched);
        i9e_close();
        para_log = stderr_log;
 out:
        i9e_close();
        para_log = stderr_log;
 out: