EMBRACE(.name = f->name, .parent = parent,
.handler = f->execute, .context = fn));
- f->open(fn);
+ if (f->open)
+ f->open(fn);
sprintf(buf, "%s (slot %d)", f->name, (int)(s - slot));
fn->task = task_register(&(struct task_info) {
.name = buf,
ti.pre_select = f->pre_select;
ti.post_select = f->post_select;
ti.context = fn;
- f->open(fn);
+ if (f->open)
+ f->open(fn);
fn->task = task_register(&ti, &s);
parent = fn->btrn;
}
/**
* Open one instance of this filter.
*
- * This should allocate the output buffer of the given filter node and do any
- * other filter-specific preparations like initializing the private_data member
- * of \a fn suitably. The open function is assumed to succeed.
+ * This should allocate the output buffer of the given filter node and
+ * do any other filter-specific preparations like initializing the
+ * private_data member of \a fn suitably. The open function is
+ * optional, If it is provided, it is assumed to succeed.
*/
void (*open)(struct filter_node *fn);
/**
* Close one instance of this filter.
*
- * Free all resources of associated with \a fn that were previously allocated
- * by the open() function. It's OK to leave this alone if the filter does not
- * need any cleanups.
+ * Free all resources associated with \a fn that were previously
+ * allocated by the open() function. It's OK to set this to NULL if the
+ * filter does not need to perform any cleanup operation.
*/
void (*close)(struct filter_node *fn);
/**
pt->fn.btrn = btr_new_node(&(struct btr_node_description)
EMBRACE(.name = decoder->name, .parent = pt->rn.btrn,
.handler = decoder->execute, .context = &pt->fn));
- decoder->open(&pt->fn);
+ if (decoder->open)
+ decoder->open(&pt->fn);
/* setup default writer */
pt->wn.conf = check_writer_arg_or_die(NULL, &pt->wn.writer_num);