From 796b99cf0b4d6bee4cff49a0acf9e4f700d82def Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Fri, 10 May 2019 17:26:29 +0300 Subject: [PATCH] Testbench: Fix file read/write component to work with pipelines This patch fixes the freeze problem when running pipeline in testbench. The file read/write component needs to use similar logic to determine number of frames to process as the the components under test those have been updated to work with timer based scheduling. Signed-off-by: Seppo Ingalsuo --- tools/testbench/file.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/testbench/file.c b/tools/testbench/file.c index eb7a1d6c3..6e07288d9 100644 --- a/tools/testbench/file.c +++ b/tools/testbench/file.c @@ -580,6 +580,8 @@ static int file_copy(struct comp_dev *dev) struct comp_buffer *buffer; struct file_comp_data *cd = comp_get_drvdata(dev); int ret = 0, bytes; + int snk_frames; + int src_frames; switch (cd->fs.mode) { case FILE_READ: @@ -588,9 +590,10 @@ static int file_copy(struct comp_dev *dev) source_list); /* test sink has enough free frames */ - if (buffer->free >= cd->period_bytes && !cd->fs.reached_eof) { + snk_frames = buffer->free / comp_frame_bytes(buffer->sink); + if (snk_frames > 0 && !cd->fs.reached_eof) { /* read PCM samples from file */ - ret = cd->file_func(dev, buffer, NULL, dev->frames); + ret = cd->file_func(dev, buffer, NULL, snk_frames); /* update sink buffer pointers */ bytes = dev->params.sample_container_bytes; @@ -605,9 +608,10 @@ static int file_copy(struct comp_dev *dev) struct comp_buffer, sink_list); /* test source has enough free frames */ - if (buffer->avail >= cd->period_bytes) { + src_frames = buffer->avail / comp_frame_bytes(buffer->source); + if (src_frames > 0) { /* write PCM samples into file */ - ret = cd->file_func(dev, NULL, buffer, dev->frames); + ret = cd->file_func(dev, NULL, buffer, src_frames); /* update source buffer pointers */ bytes = dev->params.sample_container_bytes;