From f5d35037ce8ca58864f209f359d5ad14e17641b8 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 17 Feb 2026 16:45:04 +0200 Subject: [PATCH] module: cadence: Implement complete process flow with INPUT_OVER+QUERY_DONE The full processing command flow should start with the INPUT_OVER command when EOS is expected and after the DO_EXECUTE the DONE needs to be checked to see if the decoding has completed. This does not work in the AAC library for some reason, but it will produce one empty frame at the end of the stream, which we can use to detect EOS completion. Signed-off-by: Peter Ujfalusi --- src/audio/module_adapter/module/cadence.c | 35 +++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/audio/module_adapter/module/cadence.c b/src/audio/module_adapter/module/cadence.c index f8157d8f1d67..fbec980ccef9 100644 --- a/src/audio/module_adapter/module/cadence.c +++ b/src/audio/module_adapter/module/cadence.c @@ -476,6 +476,7 @@ int cadence_codec_process_data(struct processing_module *mod) struct cadence_codec_data *cd = module_get_private_data(mod); struct module_data *codec = &mod->priv; struct comp_dev *dev = mod->dev; + uint32_t done = 0; int ret; if (codec->mpd.eos_reached) { @@ -485,6 +486,18 @@ int cadence_codec_process_data(struct processing_module *mod) return 0; } + if (dev->pipeline->expect_eos) { + /* Signal that the stream is expected to end anytime soon */ + API_CALL(cd, XA_API_CMD_INPUT_OVER, 0, NULL, ret); + if (ret != LIB_NO_ERROR) { + if (LIB_IS_FATAL_ERROR(ret)) { + comp_err(dev, "input_over failed with error: %x", ret); + return ret; + } + comp_warn(dev, "input_over failed with nonfatal error: %x", ret); + } + } + API_CALL(cd, XA_API_CMD_SET_INPUT_BYTES, 0, &codec->mpd.avail, ret); if (ret != LIB_NO_ERROR) { comp_err(dev, "failed to set size of input data with error: %x:", ret); @@ -500,6 +513,15 @@ int cadence_codec_process_data(struct processing_module *mod) comp_warn(dev, "processing failed with nonfatal error: %x", ret); } + API_CALL(cd, XA_API_CMD_EXECUTE, XA_CMD_TYPE_DONE_QUERY, &done, ret); + if (ret != LIB_NO_ERROR) { + if (LIB_IS_FATAL_ERROR(ret)) { + comp_err(dev, "done query failed with error: %x", ret); + return ret; + } + comp_warn(dev, "done query failed with nonfatal error: %x", ret); + } + API_CALL(cd, XA_API_CMD_GET_OUTPUT_BYTES, 0, &codec->mpd.produced, ret); if (ret != LIB_NO_ERROR) { comp_err(dev, "could not get produced bytes, error %x:", @@ -513,8 +535,17 @@ int cadence_codec_process_data(struct processing_module *mod) return ret; } - if (!codec->mpd.produced && dev->pipeline->expect_eos) - codec->mpd.eos_reached = true; + if (dev->pipeline->expect_eos) { + /* + * AAC decoder cannot signal DONE, check if it stopped + * producing data when EOS is expected + */ + if (cd->api_id == CADENCE_CODEC_AAC_DEC_ID && !codec->mpd.produced) + done = true; + + if (done) + codec->mpd.eos_reached = true; + } return 0; }