KPB: add function to clear history buffer

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
This commit is contained in:
Marcin Rajwa 2019-04-09 12:30:36 +02:00 committed by Tomasz Lauda
parent 5acf40a3f9
commit 0956da7be7
1 changed files with 25 additions and 1 deletions

View File

@ -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 = {