/** the local listening socket */
int fd;
/** the associated task structure */
- struct task task;
+ struct task *task;
};
/** iterate over all supported audio formats */
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;
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)
.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;