static int aacdec_post_select(__a_unused struct sched *s, struct task *t)
{
- struct filter_node *fn = container_of(t, struct filter_node, task);
+ struct filter_node *fn = task_context(t);
struct btr_node *btrn = fn->btrn;
struct private_aacdec_data *padd = fn->private_data;
int i, ret;
static int amp_post_select(__a_unused struct sched *s, struct task *t)
{
- struct filter_node *fn = container_of(t, struct filter_node, task);
+ struct filter_node *fn = task_context(t);
struct private_amp_data *pad = fn->private_data;
struct btr_node *btrn = fn->btrn;
int ret, factor = 64 + pad->amp;
if (f->close)
f->close(fn);
btr_remove_node(&fn->btrn);
+ task_reap(&fn->task);
}
free(s->fns);
s->fns = NULL;
s->fns = para_calloc(nf * sizeof(struct filter_node));
parent = s->receiver_node->btrn;
for (i = 0; i < nf; i++) {
+ char buf[20];
struct filter *f = filters + a->filter_nums[i];
fn = s->fns + i;
fn->filter_num = a->filter_nums[i];
fn->conf = a->filter_conf[i];
- fn->task.pre_select = f->pre_select;
- fn->task.post_select = f->post_select;
fn->btrn = btr_new_node(&(struct btr_node_description)
EMBRACE(.name = f->name, .parent = parent,
.handler = f->execute, .context = fn));
f->open(fn);
- register_task(&sched, &fn->task);
+ sprintf(buf, "%s (slot %d)", f->name, (int)(s - slot));
+ fn->task = task_register(&(struct task_info) {
+ .name = buf,
+ .pre_select = f->pre_select,
+ .post_select = f->post_select,
+ .context = fn,
+ }, &sched);
parent = fn->btrn;
PARA_NOTICE_LOG("%s filter %d/%d (%s) started in slot %d\n",
audio_formats[s->format], i, nf, f->name, (int)(s - slot));
- sprintf(fn->task.status, "%s (slot %d)", f->name, (int)(s - slot));
}
}
if (s->receiver_node && s->receiver_node->task->error >= 0)
return false;
for (i = 0; i < a->num_filters; i++)
- if (s->fns && s->fns[i].task.error >= 0)
+ if (s->fns && s->fns[i].task->error >= 0)
return false;
if (a->num_writers > 0) {
for (i = 0; i < a->num_writers; i++)
static int compress_post_select(__a_unused struct sched *s, struct task *t)
{
- struct filter_node *fn = container_of(t, struct filter_node, task);
+ struct filter_node *fn = task_context(t);
struct private_compress_data *pcd = fn->private_data;
struct btr_node *btrn = fn->btrn;
bool inplace = btr_inplace_ok(btrn);
static int fecdec_post_select(__a_unused struct sched *s, struct task *t)
{
- struct filter_node *fn = container_of(t, struct filter_node, task);
+ struct filter_node *fn = task_context(t);
struct btr_node *btrn = fn->btrn;
int ret;
struct fec_header h;
for (i = 0, parent = sit->btrn; i < conf.filter_given; i++) {
char *fa = conf.filter_arg[i];
struct filter_node *fn;
+ struct task_info ti;
fn = fns[i] = para_calloc(sizeof(*fn));
ret = check_filter_arg(fa, &fn->conf);
}
fn->filter_num = ret;
f = filters + fn->filter_num;
- sprintf(fn->task.status, "%s", f->name);
PARA_DEBUG_LOG("filter #%d: %s\n", i, f->name);
fn->btrn = btr_new_node(&(struct btr_node_description)
EMBRACE(.name = f->name, .parent = parent,
.handler = f->execute, .context = fn));
- fn->task.pre_select = f->pre_select;
- fn->task.post_select = f->post_select;
+ ti.name = f->name;
+ ti.pre_select = f->pre_select;
+ ti.post_select = f->post_select;
+ ti.context = fn;
f->open(fn);
- register_task(&s, &fn->task);
+ fn->task = task_register(&ti, &s);
parent = fn->btrn;
}
sot->btrn = btr_new_node(&(struct btr_node_description)
/** The buffer tree node. */
struct btr_node *btrn;
/** The task corresponding to this filter node. */
- struct task task;
+ struct task *task;
/** The minimal input queue size, see \ref btr_node_status(). */
size_t min_iqs;
};
*/
void generic_filter_pre_select(struct sched *s, struct task *t)
{
- struct filter_node *fn = container_of(t, struct filter_node, task);
+ struct filter_node *fn = task_context(t);
if (btr_node_status(fn->btrn, fn->min_iqs, BTR_NT_INTERNAL) != 0)
sched_min_delay(s);
static void flacdec_pre_select(struct sched *s, struct task *t)
{
- struct filter_node *fn = container_of(t, struct filter_node, task);
+ struct filter_node *fn = task_context(t);
struct private_flacdec_data *pfd = fn->private_data;
struct btr_node *btrn = fn->btrn;
int ret;
static int flacdec_post_select(__a_unused struct sched *s, struct task *t)
{
- struct filter_node *fn = container_of(t, struct filter_node, task);
+ struct filter_node *fn = task_context(t);
struct private_flacdec_data *pfd = fn->private_data;
struct btr_node *btrn = fn->btrn;
int ret;
static int mp3dec_post_select(__a_unused struct sched *s, struct task *t)
{
- struct filter_node *fn = container_of(t, struct filter_node, task);
+ struct filter_node *fn = task_context(t);
int i, ret;
struct private_mp3dec_data *pmd = fn->private_data;
struct btr_node *btrn = fn->btrn;
static void ogg_pre_select(struct sched *s, struct task *t)
{
- struct filter_node *fn = container_of(t, struct filter_node, task);
+ struct filter_node *fn = task_context(t);
struct private_oggdec_data *pod = fn->private_data;
struct btr_node *btrn = fn->btrn;
int ret;
static int ogg_post_select(__a_unused struct sched *s, struct task *t)
{
- struct filter_node *fn = container_of(t, struct filter_node, task);
+ struct filter_node *fn = task_context(t);
struct private_oggdec_data *pod = fn->private_data;
struct btr_node *btrn = fn->btrn;
int ret, have;
static int opusdec_post_select(__a_unused struct sched *s, struct task *t)
{
- struct filter_node *fn = container_of(t, struct filter_node, task);
+ struct filter_node *fn = task_context(t);
struct opusdec_context *ctx = fn->private_data;
struct btr_node *btrn = fn->btrn;
int ret;
static void opusdec_pre_select(struct sched *s, struct task *t)
{
- struct filter_node *fn = container_of(t, struct filter_node, task);
+ struct filter_node *fn = task_context(t);
struct opusdec_context *ctx = fn->private_data;
int ret = btr_node_status(fn->btrn, fn->min_iqs, BTR_NT_INTERNAL);
if (err >= 0)
return 0;
- if (pt->fn.task.error >= 0)
+ if (pt->fn.task->error >= 0)
return 0;
if (pt->rn.task->error >= 0)
return 0;
w->free_config(pt->wn.conf);
memset(&pt->wn, 0, sizeof(struct writer_node));
+ task_reap(&pt->fn.task);
decoder->close(&pt->fn);
btr_remove_node(&pt->fn.btrn);
free(pt->fn.conf);
static int load_file(struct play_task *pt)
{
const char *af;
- char *tmp;
+ char *tmp, buf[20];
int ret;
struct filter *decoder;
if (ret < 0)
return ret;
} else {
- char buf[20];
pt->rn.btrn = new_recv_btrn(&pt->rn);
sprintf(buf, "repos %lu", pt->start_chunk);
ret = btr_exec_up(pt->rn.btrn, buf, &tmp);
goto fail;
pt->fn.filter_num = ret;
decoder = filters + ret;
- pt->fn.task.pre_select = decoder->pre_select;
- pt->fn.task.post_select = decoder->post_select;
- sprintf(pt->fn.task.status, "%s decoder", af);
pt->fn.btrn = btr_new_node(&(struct btr_node_description)
EMBRACE(.name = decoder->name, .parent = pt->rn.btrn,
.handler = decoder->execute, .context = &pt->fn));
.post_select = afh_recv->post_select,
.context = &pt->rn
}, &sched);
- register_task(&sched, &pt->fn.task);
+ sprintf(buf, "%s decoder", af);
+ pt->fn.task = task_register(
+ &(struct task_info) {
+ .name = buf,
+ .pre_select = decoder->pre_select,
+ .post_select = decoder->post_select,
+ .context = &pt->fn
+ }, &sched);
register_writer_node(&pt->wn, pt->fn.btrn, &sched);
return 1;
fail:
static void prebuffer_pre_select(struct sched *s, struct task *t)
{
- struct filter_node *fn = container_of(t, struct filter_node, task);
+ struct filter_node *fn = task_context(t);
struct btr_node *btrn = fn->btrn;
size_t iqs = btr_get_input_queue_size(btrn);
struct private_prebuffer_data *ppd = fn->private_data;
static int prebuffer_post_select(__a_unused struct sched *s, struct task *t)
{
- struct filter_node *fn = container_of(t, struct filter_node, task);
+ struct filter_node *fn = task_context(t);
struct btr_node *btrn = fn->btrn;
size_t iqs = btr_get_input_queue_size(btrn);
struct private_prebuffer_data *ppd = fn->private_data;
static void resample_pre_select(struct sched *s, struct task *t)
{
- struct filter_node *fn = container_of(t, struct filter_node, task);
+ struct filter_node *fn = task_context(t);
struct resample_context *ctx = fn->private_data;
int ret = btr_node_status(fn->btrn, fn->min_iqs, BTR_NT_INTERNAL);
static int resample_post_select(__a_unused struct sched *s, struct task *t)
{
int ret;
- struct filter_node *fn = container_of(t, struct filter_node, task);
+ struct filter_node *fn = task_context(t);
struct resample_context *ctx = fn->private_data;
struct resample_filter_args_info *conf = fn->conf;
struct btr_node *btrn = fn->btrn;
static int speexdec_post_select(__a_unused struct sched *s, struct task *t)
{
- struct filter_node *fn = container_of(t, struct filter_node, task);
+ struct filter_node *fn = task_context(t);
struct private_spxdec_data *psd = fn->private_data;
struct btr_node *btrn = fn->btrn;
int ret, ns;
static void sync_pre_select(struct sched *s, struct task *t)
{
int ret;
- struct filter_node *fn = container_of(t, struct filter_node, task);
+ struct filter_node *fn = task_context(t);
struct sync_filter_context *ctx = fn->private_data;
struct sync_filter_config *sfc = fn->conf;
static int sync_post_select(__a_unused struct sched *s, struct task *t)
{
int ret;
- struct filter_node *fn = container_of(t, struct filter_node, task);
+ struct filter_node *fn = task_context(t);
struct sync_filter_context *ctx = fn->private_data;
struct sync_filter_config *sfc = fn->conf;
struct sync_buddy *buddy, *tmp;
static void wav_pre_select(struct sched *s, struct task *t)
{
- struct filter_node *fn = container_of(t, struct filter_node, task);
+ struct filter_node *fn = task_context(t);
size_t iqs = btr_get_input_queue_size(fn->btrn);
if (iqs == 0)
static int wav_post_select(__a_unused struct sched *s, struct task *t)
{
- struct filter_node *fn = container_of(t, struct filter_node, task);
+ struct filter_node *fn = task_context(t);
struct btr_node *btrn = fn->btrn;
size_t iqs = btr_get_input_queue_size(btrn);
int ret;
static int wmadec_post_select(__a_unused struct sched *s, struct task *t)
{
- struct filter_node *fn = container_of(t, struct filter_node, task);
+ struct filter_node *fn = task_context(t);
int ret, converted, out_size;
struct private_wmadec_data *pwd = fn->private_data;
struct btr_node *btrn = fn->btrn;