mirror of https://github.com/thesofproject/sof.git
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:
parent
c6f1b08fd2
commit
f9ec396b8f
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue