From 0956da7be7345303ab8be6e7b8240f4c9361a99e Mon Sep 17 00:00:00 2001 From: Marcin Rajwa Date: Tue, 9 Apr 2019 12:30:36 +0200 Subject: [PATCH] KPB: add function to clear history buffer Signed-off-by: Marcin Rajwa --- src/audio/kpb.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/audio/kpb.c b/src/audio/kpb.c index dab5eee56..cb5a048e1 100644 --- a/src/audio/kpb.c +++ b/src/audio/kpb.c @@ -65,6 +65,7 @@ static void kpb_init_draining(struct comp_data *kpb, struct kpb_client *cli); static uint64_t kpb_draining_task(void *arg); static void kpb_buffer_data(struct comp_data *kpb, struct comp_buffer *source); static void kpb_allocate_history_buffer(struct comp_data *kpb); +static void kpb_clear_history_buffer(struct hb *buff); /** * \brief Create a key phrase buffer component. @@ -286,7 +287,8 @@ static int kpb_prepare(struct comp_dev *dev) cd->no_of_clients = 0; - /* TODO: zeroes both buffers */ + /* init history buffer */ + kpb_clear_history_buffer(cd->history_buffer); /* initialize clients data */ for (i = 0; i < KPB_MAX_NO_OF_CLIENTS; i++) { @@ -558,6 +560,28 @@ static uint64_t kpb_draining_task(void *arg) return 0; } +/** + * \brief Initialize history buffer by zeroing its memory. + * \param[in] buff - pointer to current history buffer. + * + * \return: none. + */ +static void kpb_clear_history_buffer(struct hb *buff) +{ + struct hb *first_buff = buff; + void *start_addr; + size_t size; + + do { + start_addr = buff->start_addr; + size = start_addr - buff->end_addr; + + bzero(start_addr, size); + + buff = buff->next; + } while (buff != first_buff); +} + struct comp_driver comp_kpb = { .type = SOF_COMP_KPB, .ops = {