Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions src/audio/pipeline.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <sof/lib/cache.h>
#include <sof/lib/cpu.h>
#include <sof/list.h>
#include <sof/math/numbers.h>
#include <sof/schedule/schedule.h>
#include <sof/schedule/task.h>
#include <sof/spinlock.h>
Expand Down Expand Up @@ -246,6 +247,25 @@ int pipeline_free(struct pipeline *p)
return 0;
}

static int pipeline_comp_period_frames(struct comp_dev *current)
{
int samplerate;
int period;

period = current->pipeline->ipc_pipe.period;

if (current->output_rate)
samplerate = current->output_rate;
else
samplerate = current->params.rate;

/* Samplerate is in kHz and period in microseconds.
* As we don't have floats use scale divider 1000000.
* Also integer round up the result.
*/
return ceil_divide(samplerate * period, 1000000);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#include <sof/math/numbers.h>

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thinks it is coming from component.h... so do you want me to include it explicitly to pipeline.h?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry pipeline.c...

@tlauda tlauda Aug 28, 2019 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the best practice is to include headers explicitly, so you won't be surprised during refactor.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, got it and updated.

}

static int pipeline_comp_params(struct comp_dev *current, void *data, int dir)
{
struct pipeline_data *ppl_data = data;
Expand Down Expand Up @@ -285,16 +305,8 @@ 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;
}
/* set frames from samplerate/period */
current->frames = pipeline_comp_period_frames(current);

err = comp_params(current);
if (err < 0 || err == PPL_STATUS_PATH_STOP)
Expand Down