int mISDN_dsp_element_register(struct mISDN_dsp_element *elem)
{ struct dsp_element_entry *entry; int ret, i;
if (!elem) return -EINVAL;
entry = kzalloc(sizeof(struct dsp_element_entry), GFP_ATOMIC); if (!entry) return -ENOMEM;
INIT_LIST_HEAD(&entry->list);
entry->elem = elem;
entry->dev.class = &elements_class;
entry->dev.release = mISDN_dsp_dev_release;
dev_set_drvdata(&entry->dev, elem);
dev_set_name(&entry->dev, "%s", elem->name);
ret = device_register(&entry->dev); if (ret) {
printk(KERN_ERR "%s: failed to register %s\n",
__func__, elem->name); goto err1;
}
list_add_tail(&entry->list, &dsp_elements);
for (i = 0; i < ARRAY_SIZE(element_attributes); ++i) {
ret = device_create_file(&entry->dev,
&element_attributes[i]); if (ret) {
printk(KERN_ERR "%s: failed to create device file\n",
__func__); goto err2;
}
}
list_for_each_entry_safe(entry, n, &dsp_elements, list) if (entry->elem == elem) {
device_unregister(&entry->dev); return;
}
printk(KERN_ERR "%s: element %s not in list.\n", __func__, elem->name);
}
EXPORT_SYMBOL(mISDN_dsp_element_unregister);
int dsp_pipeline_module_init(void)
{ int err;
err = class_register(&elements_class); if (err) return err;
list_for_each_entry_safe(entry, n, &dsp_elements, list) {
list_del(&entry->list);
printk(KERN_WARNING "%s: element was still registered: %s\n",
__func__, entry->elem->name);
kfree(entry);
}
}
int dsp_pipeline_init(struct dsp_pipeline *pipeline)
{ if (!pipeline) return -EINVAL;
int dsp_pipeline_build(struct dsp_pipeline *pipeline, constchar *cfg)
{ int found = 0; char *dup, *next, *tok, *name, *args; struct dsp_element_entry *entry, *n; struct dsp_pipeline_entry *pipeline_entry; struct mISDN_dsp_element *elem;
if (!pipeline) return -EINVAL;
if (!list_empty(&pipeline->list))
_dsp_pipeline_destroy(pipeline);
dup = next = kstrdup(cfg, GFP_ATOMIC); if (!dup) return 0; while ((tok = strsep(&next, "|"))) { if (!strlen(tok)) continue;
name = strsep(&tok, "(");
args = strsep(&tok, ")"); if (args && !*args)
args = NULL;
list_for_each_entry_safe(entry, n, &dsp_elements, list) if (!strcmp(entry->elem->name, name)) {
elem = entry->elem;
pipeline_entry = kmalloc(sizeof(struct
dsp_pipeline_entry), GFP_ATOMIC); if (!pipeline_entry) {
printk(KERN_ERR "%s: failed to add " "entry to pipeline: %s (out of " "memory)\n", __func__, elem->name); goto _out;
}
pipeline_entry->elem = elem;
if (elem == dsp_hwec) { /* This is a hack to make the hwec
available as a pipeline module */
dsp_hwec_enable(container_of(pipeline, struct dsp, pipeline), args);
list_add_tail(&pipeline_entry->list,
&pipeline->list);
} else {
pipeline_entry->p = elem->new(args); if (pipeline_entry->p) {
list_add_tail(&pipeline_entry->
list, &pipeline->list);
} else {
printk(KERN_ERR "%s: failed " "to add entry to pipeline: " "%s (new() returned NULL)\n",
__func__, elem->name);
kfree(pipeline_entry);
}
}
found = 1; break;
}
if (found)
found = 0; else
printk(KERN_ERR "%s: element not found, skipping: " "%s\n", __func__, name);
}
_out: if (!list_empty(&pipeline->list))
pipeline->inuse = 1; else
pipeline->inuse = 0;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.