From e2f2e707abc1c6eadb7e25a65f321e7cbcc0e2eb Mon Sep 17 00:00:00 2001 From: Eddy Hsu Date: Fri, 23 Aug 2024 15:16:08 +0000 Subject: [PATCH] comp: ctc: properly set up and clean component state. Check CTC state is properly inited and cleanup. Signed-off-by: Eddy Hsu --- src/audio/google/google_ctc_audio_processing.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/audio/google/google_ctc_audio_processing.c b/src/audio/google/google_ctc_audio_processing.c index d7d0274bfb3f..ecdb656fa6e1 100644 --- a/src/audio/google/google_ctc_audio_processing.c +++ b/src/audio/google/google_ctc_audio_processing.c @@ -243,6 +243,8 @@ static int ctc_free(struct processing_module *mod) { struct google_ctc_audio_processing_comp_data *cd = module_get_private_data(mod); + comp_info(mod->dev, "ctc_free()"); + if (cd) { rfree(cd->input); rfree(cd->output); @@ -399,11 +401,17 @@ static int ctc_prepare(struct processing_module *mod, static int ctc_reset(struct processing_module *mod) { struct google_ctc_audio_processing_comp_data *cd = module_get_private_data(mod); + size_t buf_size = cd->chunk_frames * sizeof(cd->input[0]) * kMaxChannels; comp_info(mod->dev, "ctc_reset()"); GoogleCtcAudioProcessingFree(cd->state); + cd->state = NULL; cd->ctc_func = NULL; + cd->input_samples = 0; + cd->next_avail_output_samples = 0; + memset(cd->input, 0, buf_size); + memset(cd->output, 0, buf_size); return 0; }