pipeline: refine pipeline_free() function

This change allows us to free components and pipelines
in any order. Added setting component pointer to NULL
after comp_free() invocation. In pipeline_free() there is
a incovation of pipeline_comp_free() only if component
pointer is not NULL.

Signed-off-by: Bartosz Kokoszko <bartoszx.kokoszko@linux.intel.com>
This commit is contained in:
Bartosz Kokoszko 2019-07-19 10:23:04 +02:00 committed by Janusz Jankowski
parent 9d7aea477b
commit de2e08a07a
2 changed files with 27 additions and 12 deletions

View File

@ -216,21 +216,23 @@ int pipeline_free(struct pipeline *p)
trace_pipe_with_ids(p, "pipeline_free()");
/* make sure we are not in use */
if (p->source_comp) {
if (p->source_comp->state > COMP_STATE_READY) {
trace_pipe_error_with_ids(p, "pipeline_free() error: Pipeline"
" in use, %u, %u",
trace_pipe_error_with_ids(p, "pipeline_free() error: "
"Pipeline in use, %u, %u",
p->source_comp->comp.id,
p->source_comp->state);
return -EBUSY;
}
/* remove from any scheduling */
schedule_task_free(&p->pipe_task);
data.start = p->source_comp;
/* disconnect components */
pipeline_comp_free(p->source_comp, &data, PPL_DIR_DOWNSTREAM);
}
/* remove from any scheduling */
schedule_task_free(&p->pipe_task);
/* now free the pipeline */
rfree(p);

View File

@ -170,6 +170,19 @@ int ipc_comp_free(struct ipc *ipc, uint32_t comp_id)
/* free component and remove from list */
comp_free(icd->cd);
/* set pipeline sink/source/sched pointers to NULL if needed */
if (icd->cd->pipeline) {
if (icd->cd == icd->cd->pipeline->source_comp)
icd->cd->pipeline->source_comp = NULL;
if (icd->cd == icd->cd->pipeline->sink_comp)
icd->cd->pipeline->sink_comp = NULL;
if (icd->cd == icd->cd->pipeline->sched_comp)
icd->cd->pipeline->sched_comp = NULL;
}
icd->cd = NULL;
list_item_del(&icd->list);
rfree(icd);
@ -343,7 +356,7 @@ int ipc_pipeline_free(struct ipc *ipc, uint32_t comp_id)
"pipeline_free() failed");
return ret;
}
ipc_pipe->pipeline = NULL;
list_item_del(&ipc_pipe->list);
rfree(ipc_pipe);