task_register() conversion: audiod command task
authorAndre Noll <maan@systemlinux.org>
Tue, 31 Dec 2013 00:01:12 +0000 (00:01 +0000)
committerAndre Noll <maan@systemlinux.org>
Sun, 25 May 2014 13:39:00 +0000 (15:39 +0200)
audiod.c

index 948204d..aa75741 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -168,7 +168,7 @@ struct command_task {
        /** the local listening socket */
        int fd;
        /** the associated task structure */
-       struct task task;
+       struct task *task;
 };
 
 /** iterate over all supported audio formats */
@@ -1027,14 +1027,14 @@ static int signal_post_select(struct sched *s, __a_unused struct task *t)
 
 static void command_pre_select(struct sched *s, struct task *t)
 {
-       struct command_task *ct = container_of(t, struct command_task, task);
+       struct command_task *ct = task_context(t);
        para_fd_set(ct->fd, &s->rfds, &s->max_fileno);
 }
 
 static int command_post_select(struct sched *s, struct task *t)
 {
        int ret;
-       struct command_task *ct = container_of(t, struct command_task, task);
+       struct command_task *ct = task_context(t);
        static struct timeval last_status_dump;
        struct timeval tmp, delay;
        bool force = true;
@@ -1069,11 +1069,14 @@ dump:
 
 static void init_command_task(struct command_task *ct)
 {
-       ct->task.pre_select = command_pre_select;
-       ct->task.post_select = command_post_select;
-       ct->task.error = 0;
        ct->fd = audiod_get_socket(); /* doesn't return on errors */
-       sprintf(ct->task.status, "command task");
+
+       ct->task = task_register(&(struct task_info) {
+               .name = "command",
+               .pre_select = command_pre_select,
+               .post_select = command_post_select,
+               .context = ct,
+       }, &sched);
 }
 
 static void close_stat_pipe(void)
@@ -1429,7 +1432,7 @@ int main(int argc, char *argv[])
                .post_select = signal_post_select,
                .context = sig_task,
        }, &sched);
-       register_task(&sched, &cmd_task->task);
+
        register_task(&sched, &stat_task->task);
        sched.default_timeout.tv_sec = 2;
        sched.default_timeout.tv_usec = 999 * 1000;