pipeline: calculate frame count from stream params

Previously frame count was coming as topology pipeline parameter. As the
frame count might change because of some components have fixed
samplerate, we might as well calculate it from the stream parameters.
Component base struct will have new member output_rate, which the
component should set if it has fixed output rate (like SRC). Not setting
it or 0 means it can be whatever the pipeline decides. Components with 0
output_rate will have frames = (stream) sample_rate / (pipeline)
deadline. Components downstream to fixed output rate will obey the fixed
rate / period.

Signed-off-by: Jaska Uimonen <jaska.uimonen@intel.com>
This commit is contained in:
Jaska Uimonen 2019-01-24 11:09:12 +02:00 committed by Tomasz Lauda
parent c6f1b08fd2
commit f9ec396b8f
3 changed files with 14 additions and 1 deletions

View File

@ -144,7 +144,6 @@ static int pipeline_comp_complete(struct comp_dev *current, void *data,
/* complete component init */
current->pipeline = ppl_data->p;
current->frames = ppl_data->p->ipc_pipe.frames_per_sched;
pipeline_for_each_comp(current, &pipeline_comp_complete, data,
NULL, dir);
@ -286,6 +285,17 @@ static int pipeline_comp_params(struct comp_dev *current, void *data, int dir)
/* send current params to the component */
current->params = ppl_data->params->params;
/* set frames from samplerate/period, but round integer up */
if (current->output_rate != 0) {
current->frames = (current->output_rate +
current->pipeline->ipc_pipe.period - 1) /
current->pipeline->ipc_pipe.period;
} else {
current->frames = (current->params.rate +
current->pipeline->ipc_pipe.period - 1) /
current->pipeline->ipc_pipe.period;
}
err = comp_params(current);
if (err < 0 || err == PPL_STATUS_PATH_STOP)
return err;

View File

@ -536,6 +536,8 @@ static struct comp_dev *src_new(struct sof_ipc_comp *comp)
cd->polyphase_func = src_polyphase_stage_cir;
src_polyphase_reset(&cd->src);
dev->output_rate = ipc_src->sink_rate;
dev->state = COMP_STATE_READY;
return dev;
}

View File

@ -235,6 +235,7 @@ struct comp_dev {
uint16_t is_dma_connected; /**< component is connected to DMA */
uint64_t position; /**< component rendering position */
uint32_t frames; /**< number of frames we copy to sink */
uint32_t output_rate; /**< 0 means all output rates are fine */
struct pipeline *pipeline; /**< pipeline we belong to */
/** common runtime configuration for downstream/upstream */