Skip to content

Commit

Permalink
pipeline: calculate frame count from stream params
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jaska Uimonen authored and tlauda committed Aug 15, 2019
1 parent c6f1b08 commit f9ec396
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/audio/pipeline.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/audio/src/src.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions src/include/sof/audio/component.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit f9ec396

Please sign in to comment.