diff --git a/src/audio/pipeline.c b/src/audio/pipeline.c index 62bd02c46..cb5386d98 100644 --- a/src/audio/pipeline.c +++ b/src/audio/pipeline.c @@ -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; diff --git a/src/audio/src/src.c b/src/audio/src/src.c index 5b090f673..25bd535fd 100644 --- a/src/audio/src/src.c +++ b/src/audio/src/src.c @@ -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; } diff --git a/src/include/sof/audio/component.h b/src/include/sof/audio/component.h index b9c1b85c7..91c894714 100644 --- a/src/include/sof/audio/component.h +++ b/src/include/sof/audio/component.h @@ -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 */