Skip to content

Commit 7ee22be

Browse files
lrgirdwolgirdwood
authored andcommitted
testbench: file: Add support for stopping testbench on file size/copies
Allow the testbench to stop on a file size or number of file(pipeline) copies. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent 0f245bf commit 7ee22be

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

tools/testbench/file.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,11 @@ static int file_s32(struct comp_dev *dev, struct audio_stream *sink,
443443
return -EINVAL;
444444
}
445445

446+
/* update sample counter and check if we have a sample limit */
446447
cd->fs.n += n_samples;
448+
if (cd->max_samples && cd->fs.n >= cd->max_samples)
449+
cd->fs.reached_eof = 1;
450+
447451
return n_samples;
448452
}
449453

@@ -473,7 +477,11 @@ static int file_s16(struct comp_dev *dev, struct audio_stream *sink,
473477
return -EINVAL;
474478
}
475479

480+
/* update sample counter and check if we have a sample limit */
476481
cd->fs.n += n_samples;
482+
if (cd->max_samples && cd->fs.n >= cd->max_samples)
483+
cd->fs.reached_eof = 1;
484+
477485
return n_samples;
478486
}
479487

@@ -503,7 +511,11 @@ static int file_s24(struct comp_dev *dev, struct audio_stream *sink,
503511
return -EINVAL;
504512
}
505513

514+
/* update sample counter and check if we have a sample limit */
506515
cd->fs.n += n_samples;
516+
if (cd->max_samples && cd->fs.n >= cd->max_samples)
517+
cd->fs.reached_eof = 1;
518+
507519
return n_samples;
508520
}
509521

@@ -603,6 +615,7 @@ static struct comp_dev *file_new(const struct comp_driver *drv,
603615
cd->fs.reached_eof = false;
604616
cd->fs.write_failed = false;
605617
cd->fs.n = 0;
618+
cd->fs.copy_count = 0;
606619
dev->state = COMP_STATE_READY;
607620
return dev;
608621

@@ -772,6 +785,14 @@ static int file_copy(struct comp_dev *dev)
772785
break;
773786
}
774787

788+
cd->fs.copy_count++;
789+
if (cd->fs.reached_eof || (cd->max_copies && cd->fs.copy_count >= cd->max_copies)) {
790+
cd->fs.reached_eof = 1;
791+
comp_info(dev, "file_copy(): copies %d max %d eof %d",
792+
cd->fs.copy_count, cd->max_copies,
793+
cd->fs.reached_eof);
794+
schedule_task_cancel(dev->pipeline->pipe_task);
795+
}
775796
return ret;
776797
}
777798

tools/testbench/include/testbench/file.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ struct file_state {
3636
int n;
3737
enum file_mode mode;
3838
enum file_format f_format;
39+
int copy_count;
3940
};
4041

4142
/* file comp data */
@@ -48,6 +49,9 @@ struct file_comp_data {
4849
int (*file_func)(struct comp_dev *dev, struct audio_stream *sink,
4950
struct audio_stream *source, uint32_t frames);
5051

52+
/* maximum limits */
53+
int max_samples;
54+
int max_copies;
5155
};
5256

5357
#endif

0 commit comments

Comments
 (0)