diff --git a/src/audio/module_adapter/module_adapter.c b/src/audio/module_adapter/module_adapter.c index 048eda0d47e0..9a0bb90aaea3 100644 --- a/src/audio/module_adapter/module_adapter.c +++ b/src/audio/module_adapter/module_adapter.c @@ -226,22 +226,26 @@ struct comp_dev *module_adapter_new_ext(const struct comp_driver *drv, if (!mod) return NULL; + module_set_private_data(mod, mod_priv); + list_init(&mod->raw_data_buffers_list); +#if CONFIG_USERSPACE + mod->user_ctx = user_ctx; +#endif /* CONFIG_USERSPACE */ + struct comp_dev *dev = mod->dev; #if CONFIG_ZEPHYR_DP_SCHEDULER /* create a task for DP processing */ if (config->proc_domain == COMP_PROCESSING_DOMAIN_DP) { /* All data allocated, create a thread */ - pipeline_comp_dp_task_init(dev); + ret = pipeline_comp_dp_task_init(dev); + if (ret) { + comp_cl_err(drv, "DP task creation failed with error %d.", ret); + goto err; + } } #endif /* CONFIG_ZEPHYR_DP_SCHEDULER */ - module_set_private_data(mod, mod_priv); - list_init(&mod->raw_data_buffers_list); -#if CONFIG_USERSPACE - mod->user_ctx = user_ctx; -#endif /* CONFIG_USERSPACE */ - dst = &mod->priv.cfg; /* * NOTE: dst->ext_data points to stack variable and contains @@ -330,10 +334,6 @@ struct comp_dev *module_adapter_new_ext(const struct comp_driver *drv, schedule_task_free(dev->task); #endif module_adapter_mem_free(mod); -#if CONFIG_IPC_MAJOR_4 - dst->ext_data = NULL; -#endif - return NULL; } diff --git a/src/schedule/zephyr_dp_schedule_thread.c b/src/schedule/zephyr_dp_schedule_thread.c index e21644797310..f33cd5f6a149 100644 --- a/src/schedule/zephyr_dp_schedule_thread.c +++ b/src/schedule/zephyr_dp_schedule_thread.c @@ -262,12 +262,12 @@ int scheduler_dp_task_init(struct task **task, /* success, fill the structures */ pdata->p_stack = p_stack; pdata->mod = mod; - *task = &task_memory->task; /* create a zephyr thread for the task */ pdata->thread_id = k_thread_create(pdata->thread, (__sparse_force void *)p_stack, - stack_size, dp_thread_fn, *task, NULL, NULL, - CONFIG_DP_THREAD_PRIORITY, (*task)->flags, K_FOREVER); + stack_size, dp_thread_fn, &task_memory->task, NULL, NULL, + CONFIG_DP_THREAD_PRIORITY, task_memory->task.flags, + K_FOREVER); k_thread_access_grant(pdata->thread_id, pdata->event); scheduler_dp_grant(pdata->thread_id, cpu_get_id()); @@ -280,7 +280,7 @@ int scheduler_dp_task_init(struct task **task, } #ifdef CONFIG_USERSPACE - if ((*task)->flags & K_USER) { + if (task_memory->task.flags & K_USER) { ret = user_memory_init_shared(pdata->thread_id, pdata->mod); if (ret < 0) { tr_err(&dp_tr, "user_memory_init_shared() failed"); @@ -293,6 +293,8 @@ int scheduler_dp_task_init(struct task **task, k_event_init(pdata->event); k_thread_start(pdata->thread_id); + /* success, fill output parameter */ + *task = &task_memory->task; return 0; e_thread: