Skip to content

Commit

Permalink
kpb: simplify calculation of buffered data
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
mrajwa authored and lgirdwood committed Apr 7, 2020
1 parent ec2d1cd commit afe41bc
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/audio/kpb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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()");
Expand Down Expand Up @@ -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.");
}
Expand Down

0 comments on commit afe41bc

Please sign in to comment.