static void alsa_write_pre_select(struct sched *s, struct task *t)
{
struct pollfd pfd;
- struct writer_node *wn = container_of(t, struct writer_node, task);
+ struct writer_node *wn = task_context(t);
struct private_alsa_write_data *pad = wn->private_data;
int ret = btr_node_status(wn->btrn, wn->min_iqs, BTR_NT_LEAF);
static int alsa_write_post_select(__a_unused struct sched *s,
struct task *t)
{
- struct writer_node *wn = container_of(t, struct writer_node, task);
+ struct writer_node *wn = task_context(t);
struct private_alsa_write_data *pad = wn->private_data;
struct btr_node *btrn = wn->btrn;
char *data;
static void aow_pre_select(struct sched *s, struct task *t)
{
- struct writer_node *wn = container_of(t, struct writer_node, task);
+ struct writer_node *wn = task_context(t);
struct private_aow_data *pawd = wn->private_data;
int ret;
static int aow_post_select(__a_unused struct sched *s,
struct task *t)
{
- struct writer_node *wn = container_of(t, struct writer_node, task);
+ struct writer_node *wn = task_context(t);
struct private_aow_data *pawd = wn->private_data;
int ret;
PARA_INFO_LOG("closing %s\n", writer_names[wn->writer_num]);
w->close(wn);
btr_remove_node(&wn->btrn);
+ task_reap(&wn->task);
}
static void close_writers(struct slot_info *s)
return false;
if (a->num_writers > 0) {
for (i = 0; i < a->num_writers; i++)
- if (s->wns && s->wns[i].task.error >= 0)
+ if (s->wns && s->wns[i].task->error >= 0)
return false;
} else {
- if (s->wns && s->wns[0].task.error >= 0)
+ if (s->wns && s->wns[0].task->error >= 0)
return false;
}
return true;
static void file_write_pre_select(struct sched *s, struct task *t)
{
- struct writer_node *wn = container_of(t, struct writer_node, task);
+ struct writer_node *wn = task_context(t);
struct private_file_write_data *pfwd = wn->private_data;
int ret = btr_node_status(wn->btrn, wn->min_iqs, BTR_NT_LEAF);
static int file_write_post_select(__a_unused struct sched *s,
struct task *t)
{
- struct writer_node *wn = container_of(t, struct writer_node, task);
+ struct writer_node *wn = task_context(t);
struct private_file_write_data *pfwd = wn->private_data;
struct btr_node *btrn = wn->btrn;
int ret;
static void oss_pre_select(struct sched *s, struct task *t)
{
- struct writer_node *wn = container_of(t, struct writer_node, task);
+ struct writer_node *wn = task_context(t);
struct private_oss_write_data *powd = wn->private_data;
int ret = btr_node_status(wn->btrn, wn->min_iqs, BTR_NT_LEAF);
static int oss_post_select(__a_unused struct sched *s,
struct task *t)
{
- struct writer_node *wn = container_of(t, struct writer_node, task);
+ struct writer_node *wn = task_context(t);
struct private_oss_write_data *powd = wn->private_data;
struct btr_node *btrn = wn->btrn;
size_t frames, bytes;
static void osx_write_pre_select(struct sched *s, struct task *t)
{
- struct writer_node *wn = container_of(t, struct writer_node, task);
+ struct writer_node *wn = task_context(t);
struct private_osx_write_data *powd = wn->private_data;
int ret;
bool drain_delay_nec = false;
static int osx_write_post_select(__a_unused struct sched *s, struct task *t)
{
- struct writer_node *wn = container_of(t, struct writer_node, task);
+ struct writer_node *wn = task_context(t);
struct private_osx_write_data *powd = wn->private_data;
struct btr_node *btrn = wn->btrn;
int ret;
/* returns: 0 not eof, 1: eof, < 0: fatal error. */
static int get_playback_error(struct play_task *pt)
{
- int err = pt->wn.task.error;
+ int err;
+ if (!pt->wn.task)
+ return 0;
+ err = pt->wn.task->error;
if (err >= 0)
return 0;
if (pt->fn.task->error >= 0)
if (ret == 0)
return ret;
PARA_NOTICE_LOG("cleaning up wn/fn nodes\n");
+ task_reap(&pt->wn.task);
w->close(&pt->wn);
btr_remove_node(&pt->wn.btrn);
w->free_config(pt->wn.conf);
/* setup default writer */
pt->wn.conf = check_writer_arg_or_die(NULL, &pt->wn.writer_num);
- pt->wn.task.error = 0;
/* success, register tasks */
pt->rn.task = task_register(
static void kill_stream(struct play_task *pt)
{
- task_notify(&pt->wn.task, E_EOF);
+ if (pt->wn.task)
+ task_notify(pt->wn.task, E_EOF);
}
#ifdef HAVE_READLINE
if (ret >= 0) {
int j;
for (j = 0; j < i; j++) {
- struct task *t = &wns[j].task;
+ struct task *t = wns[j].task;
assert(t->error < 0);
if (t->error != -E_WRITE_COMMON_EOF
&& t->error != -E_BTR_EOF) {
/** The buffer tree node associated with this writer node. */
struct btr_node *btrn;
/** The task of this writer node. */
- struct task task;
+ struct task *task;
/** The minimal input queue size (size of one audio sample). */
size_t min_iqs;
};
struct sched *s)
{
struct writer *w = writers + wn->writer_num;
- char *name = make_message("%s writer", writer_names[wn->writer_num]);
wn->btrn = btr_new_node(&(struct btr_node_description)
- EMBRACE(.name = name, .parent = parent,
+ EMBRACE(.name = writer_names[wn->writer_num], .parent = parent,
.handler = w->execute, .context = wn));
- strcpy(wn->task.status, name);
- free(name);
- wn->task.pre_select = w->pre_select;
- wn->task.post_select = w->post_select;
- register_task(s, &wn->task);
+ wn->task = task_register(&(struct task_info) {
+ .name = writer_names[wn->writer_num],
+ .pre_select = w->pre_select,
+ .post_select = w->post_select,
+ .context = wn,
+ }, s);
}
/**