Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions src/audio/module_adapter/module/cadence.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
}
}
Comment on lines +489 to +499
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The INPUT_OVER command is called on every invocation of cadence_codec_process_data when expect_eos is true. This means the command will be sent repeatedly to the codec library until EOS is reached. Consider adding a flag (e.g., input_over_sent) in the cadence_codec_data structure to call INPUT_OVER only once when expect_eos transitions to true. This would be more efficient and aligns with typical codec API semantics where INPUT_OVER signals the final input has been provided. However, if the Cadence API is designed to handle repeated INPUT_OVER calls efficiently, this may not be necessary.

Copilot uses AI. Check for mistakes.

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);
Expand All @@ -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:",
Expand All @@ -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;
}
Loading