From 62c2dc7f15d4875ec86b9de7bb9a5f82413f7ac9 Mon Sep 17 00:00:00 2001
From: Andre Noll <maan@systemlinux.org>
Date: Tue, 31 Dec 2013 00:01:12 +0000
Subject: [PATCH] task_register() conversion: audiod command task

---
 audiod.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/audiod.c b/audiod.c
index 948204dc..aa757416 100644
--- 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;
-- 
2.39.5