kpb: simplify calculation of buffered data

This patch reworks the calculation of buffered data.
NOTE! We only keep record of buffered data up to
the size of history buffer as there is no usecase
beyond that.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
This commit is contained in:
Marcin Rajwa 2020-04-01 12:32:32 +02:00 committed by Liam Girdwood
parent ec2d1cd52d
commit afe41bcd53
1 changed files with 6 additions and 7 deletions

View File

@ -610,7 +610,6 @@ static int kpb_copy(struct comp_dev *dev)
struct comp_buffer *sink = NULL;
size_t copy_bytes = 0;
size_t sample_width = kpb->config.sampling_width;
uint32_t hb_free_space;
uint32_t flags = 0;
comp_dbg(dev, "kpb_copy()");
@ -679,13 +678,13 @@ static int kpb_copy(struct comp_dev *dev)
comp_err(dev, "kpb_copy(): internal buffering failed.");
goto out;
}
if (kpb->buffered_data < kpb->buffer_size) {
hb_free_space = kpb->buffer_size -
kpb->buffered_data;
kpb->hd.buffered +=
MIN(copy_bytes, hb_free_space);
}
/* Update buffered size. NOTE! We only record buffered
* data up to the size of history buffer.
*/
kpb->hd.buffered += MIN(kpb->hd.buffer_size -
kpb->hd.buffered,
copy_bytes);
} else {
comp_err(dev, "kpb_copy(): too much data to buffer.");
}