]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - audiod.c
task_register() conversion: audiod command task
[paraslash.git] / audiod.c
index 948204dc8829a78c3a4595d5a03dde48733d0462..aa757416032b3e5a0f2cd726f940aa47dd7f0212 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;