mirror of https://github.com/thesofproject/sof.git
host: allow overriding input and output sample rates through command line args
By default the input and output sample rates for the testbench will be calculated from the frames_per_sched and deadline. But this patch makes it possible for it to be overridden in preparation for support for SRC based pipelines. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This commit is contained in:
parent
f15512e920
commit
e822cfab7c
|
@ -128,14 +128,13 @@ int tb_pipeline_params(struct ipc *ipc, int nch, char *bits_in,
|
|||
struct pipeline *p;
|
||||
struct comp_dev *cd;
|
||||
struct sof_ipc_pcm_params params;
|
||||
int fs, deadline;
|
||||
int deadline;
|
||||
char message[DEBUG_MSG_LEN];
|
||||
|
||||
deadline = ipc_pipe->deadline;
|
||||
fs = deadline * ipc_pipe->frames_per_sched;
|
||||
|
||||
/* Compute period from sample rates */
|
||||
fs_period = (int)(0.9999 + fs * deadline / 1e6);
|
||||
fs_period = (int)(0.9999 + fs_in * deadline / 1e6);
|
||||
sprintf(message, "period sample count %d\n", fs_period);
|
||||
debug_print(message);
|
||||
|
||||
|
@ -144,7 +143,7 @@ int tb_pipeline_params(struct ipc *ipc, int nch, char *bits_in,
|
|||
params.params.buffer_fmt = SOF_IPC_BUFFER_INTERLEAVED;
|
||||
params.params.frame_fmt = find_format(bits_in);
|
||||
params.params.direction = SOF_IPC_STREAM_PLAYBACK;
|
||||
params.params.rate = fs;
|
||||
params.params.rate = fs_in;
|
||||
params.params.channels = nch;
|
||||
switch (params.params.frame_fmt) {
|
||||
case(SOF_IPC_FRAME_S16_LE):
|
||||
|
|
|
@ -118,6 +118,7 @@ static void print_usage(char *executable)
|
|||
printf("input_format should be S16_LE, S32_LE, S24_LE or FLOAT_LE\n");
|
||||
printf("Example Usage:\n");
|
||||
printf("%s -i in.txt -o out.txt -t test.tplg ", executable);
|
||||
printf("-r 48000 -R 96000 ");
|
||||
printf("-b S16_LE -a vol=libsof_volume.so\n");
|
||||
}
|
||||
|
||||
|
@ -180,22 +181,14 @@ int main(int argc, char **argv)
|
|||
char pipeline[DEBUG_MSG_LEN];
|
||||
clock_t tic, toc;
|
||||
double c_realtime, t_exec;
|
||||
int fs, n_in, n_out, ret;
|
||||
int n_in, n_out, ret;
|
||||
int i, option = 0;
|
||||
|
||||
/* initialize input and output sample rates */
|
||||
fs_in = 0;
|
||||
fs_out = 0;
|
||||
|
||||
/* set up shared library look up table */
|
||||
ret = set_up_library_table();
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "error: setting up shared libraried\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* set up trace class definition table from trace header */
|
||||
setup_trace_table();
|
||||
|
||||
/* command line arguments*/
|
||||
while ((option = getopt(argc, argv, "hdi:o:t:b:a:")) != -1) {
|
||||
while ((option = getopt(argc, argv, "hdi:o:t:b:a:r:R:")) != -1) {
|
||||
switch (option) {
|
||||
/* input sample file */
|
||||
case 'i':
|
||||
|
@ -222,6 +215,16 @@ int main(int argc, char **argv)
|
|||
parse_libraries(optarg);
|
||||
break;
|
||||
|
||||
/* input sample rate */
|
||||
case 'r':
|
||||
fs_in = atoi(optarg);
|
||||
break;
|
||||
|
||||
/* output sample rate */
|
||||
case 'R':
|
||||
fs_out = atoi(optarg);
|
||||
break;
|
||||
|
||||
/* enable debug prints */
|
||||
case 'd':
|
||||
debug = 1;
|
||||
|
@ -265,7 +268,12 @@ int main(int argc, char **argv)
|
|||
p = pcm_dev->cd->pipeline;
|
||||
ipc_pipe = &p->ipc_pipe;
|
||||
|
||||
fs = ipc_pipe->deadline * ipc_pipe->frames_per_sched;
|
||||
/* input and output sample rate */
|
||||
if (!fs_in)
|
||||
fs_in = ipc_pipe->deadline * ipc_pipe->frames_per_sched;
|
||||
|
||||
if (!fs_out)
|
||||
fs_out = ipc_pipe->deadline * ipc_pipe->frames_per_sched;
|
||||
|
||||
/* set pipeline params and trigger start */
|
||||
if (tb_pipeline_start(sof.ipc, TESTBENCH_NCH, bits_in, ipc_pipe) < 0) {
|
||||
|
@ -295,7 +303,7 @@ int main(int argc, char **argv)
|
|||
n_in = frcd->fs.n;
|
||||
n_out = fwcd->fs.n;
|
||||
t_exec = (double)(toc - tic) / CLOCKS_PER_SEC;
|
||||
c_realtime = (double)n_out / TESTBENCH_NCH / fs / t_exec;
|
||||
c_realtime = (double)n_out / TESTBENCH_NCH / fs_out / t_exec;
|
||||
|
||||
/* free all components/buffers in pipeline */
|
||||
free_comps();
|
||||
|
@ -310,6 +318,8 @@ int main(int argc, char **argv)
|
|||
printf("Test Pipeline:\n");
|
||||
printf("%s\n", pipeline);
|
||||
printf("Input bit format: %s\n", bits_in);
|
||||
printf("Input sample rate: %d\n", fs_in);
|
||||
printf("Output sample rate: %d\n", fs_out);
|
||||
printf("Output written to file: \"%s\"\n", output_file);
|
||||
printf("Input sample count: %d\n", n_in);
|
||||
printf("Output sample count: %d\n", n_out);
|
||||
|
|
|
@ -618,6 +618,18 @@ static int load_src(struct sof *sof, int comp_id, int pipeline_id,
|
|||
|
||||
array = (void *)array - size;
|
||||
|
||||
/* set testbench input and output sample rate from topology */
|
||||
if (!fs_out) {
|
||||
fs_out = src.sink_rate;
|
||||
|
||||
if (!fs_in)
|
||||
fs_in = src.source_rate;
|
||||
else
|
||||
src.source_rate = fs_in;
|
||||
} else {
|
||||
src.sink_rate = fs_out;
|
||||
}
|
||||
|
||||
/* configure src */
|
||||
src.comp.id = comp_id;
|
||||
src.comp.hdr.size = sizeof(struct sof_ipc_comp_src);
|
||||
|
|
|
@ -48,6 +48,14 @@ char *input_file; /* input file name */
|
|||
char *output_file; /* output file name */
|
||||
char *bits_in; /* input bit format */
|
||||
|
||||
/*
|
||||
* input and output sample rate parameters
|
||||
* By default, these are calculated from pipeline frames_per_sched and deadline
|
||||
* But they can also be overridden via input arguments to the testbench
|
||||
*/
|
||||
uint32_t fs_in;
|
||||
uint32_t fs_out;
|
||||
|
||||
#define DEBUG_MSG_LEN 256
|
||||
#define MAX_LIB_NAME_LEN 256
|
||||
|
||||
|
|
Loading…
Reference in New Issue