diff --git a/src/audio/codec_adapter/codec/cadence.c b/src/audio/codec_adapter/codec/cadence.c index 5692b6a18..1a889bf9d 100644 --- a/src/audio/codec_adapter/codec/cadence.c +++ b/src/audio/codec_adapter/codec/cadence.c @@ -254,12 +254,15 @@ err: int cadence_codec_prepare(struct comp_dev *dev) { - int ret, mem_tabs_size, lib_init_status; + int ret = 0, mem_tabs_size, lib_init_status; struct codec_data *codec = comp_get_codec(dev); struct cadence_codec_data *cd = codec->private; comp_dbg(dev, "cadence_codec_prepare() start"); + if (codec->state == CODEC_PREPARED) + goto done; + API_CALL(cd, XA_API_CMD_INIT, XA_CMD_TYPE_INIT_API_PRE_CONFIG_PARAMS, NULL, ret); if (ret != LIB_NO_ERROR) { @@ -345,6 +348,7 @@ int cadence_codec_prepare(struct comp_dev *dev) free: codec_free_memory(dev, cd->mem_tabs); err: +done: return ret; } @@ -391,8 +395,19 @@ int cadence_codec_apply_config(struct comp_dev *dev) int cadence_codec_reset(struct comp_dev *dev) { - /* Nothing to do */ - return 0; + int ret; + /* Current CADENCE API doesn't support reset of codec's + * runtime parameters therefore we need to free all the resources + * and start over. + */ + codec_free_all_memory(dev); + ret = cadence_codec_init(dev); + if (ret) { + comp_err(dev, "cadence_codec_reset() error %x: could not reinitialize codec after reset", + ret); + } + + return ret; } int cadence_codec_free(struct comp_dev *dev) diff --git a/src/audio/codec_adapter/codec/generic.c b/src/audio/codec_adapter/codec/generic.c index 0cf0e1eb5..d295b8d0b 100644 --- a/src/audio/codec_adapter/codec/generic.c +++ b/src/audio/codec_adapter/codec/generic.c @@ -217,9 +217,6 @@ int codec_prepare(struct comp_dev *dev) comp_dbg(dev, "codec_prepare() start"); - /* After reset the codec should remain prepared, hence there - * is no need to re-prepare it again. - */ if (cd->codec.state == CODEC_PREPARED) return 0; if (cd->codec.state < CODEC_INITIALIZED) @@ -328,7 +325,7 @@ int codec_reset(struct comp_dev *dev) /* Codec reset itself to the initial condition after prepare() * so let's change its state to reflect that. */ - codec->state = CODEC_PREPARED; + codec->state = CODEC_INITIALIZED; return 0; }