Skip to content

Commit

Permalink
comp: ctc: properly set up and clean component state.
Browse files Browse the repository at this point in the history
Check CTC state is properly inited and cleanup.

Signed-off-by: Eddy Hsu <eddyhsu@google.com>
  • Loading branch information
Eddy Hsu committed Sep 5, 2024
1 parent 536e99e commit 1a13d57
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/audio/google/google_ctc_audio_processing.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 1a13d57

Please sign in to comment.