module: cadence: Implement complete process flow with INPUT_OVER+QUER…#10553
module: cadence: Implement complete process flow with INPUT_OVER+QUER…#10553ujfalusi wants to merge 1 commit intothesofproject:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR implements a complete Cadence codec process flow by adding support for the INPUT_OVER and DONE_QUERY commands to properly handle End of Stream (EOS) detection. The implementation adds the INPUT_OVER signal when EOS is expected, queries the DONE status after each DO_EXECUTE operation, and includes special handling for the FLAC decoder which cannot properly signal completion.
Changes:
- Added INPUT_OVER command to signal impending stream end when
expect_eosis true - Added DONE_QUERY command after DO_EXECUTE to check if decoding has completed
- Implemented FLAC-specific workaround that detects EOS by checking if the decoder stopped producing output
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 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 = false; |
There was a problem hiding this comment.
Initialize uint32_t variable with 0 instead of false for consistency. While false evaluates to 0 and works correctly, using false to initialize an integer type is unconventional. This should be: uint32_t done = 0;
| uint32_t done = false; | |
| uint32_t done = 0; |
| */ | ||
| if (cd->api_id == CADENCE_CODEC_FLAC_DEC_ID && !codec->mpd.produced) | ||
| done = true; |
There was a problem hiding this comment.
The constant CADENCE_CODEC_FLAC_DEC_ID is not defined anywhere in the codebase. This will cause a compilation error. The enum cadence_api_id in src/include/sof/audio/module_adapter/module/cadence.h does not include a FLAC decoder entry. You need to either:
- Add CADENCE_CODEC_FLAC_DEC_ID to the enum in cadence.h
- Add the corresponding FLAC decoder entry in the cadence_api_table in cadence.c
- Add the necessary CONFIG_CADENCE_CODEC_FLAC_DEC configuration
- Declare the xa_flac_dec function if it exists
If FLAC support is not yet implemented, this code should be removed or the comparison should check against a valid codec ID.
| */ | |
| if (cd->api_id == CADENCE_CODEC_FLAC_DEC_ID && !codec->mpd.produced) | |
| done = true; | |
| */ | |
| #ifdef CADENCE_CODEC_FLAC_DEC_ID | |
| if (cd->api_id == CADENCE_CODEC_FLAC_DEC_ID && !codec->mpd.produced) | |
| done = true; | |
| #endif |
| 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); | ||
| } | ||
| } |
There was a problem hiding this comment.
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.
6e8642b to
c899911
Compare
|
Changes since v1:
|
…Y_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 <peter.ujfalusi@linux.intel.com>
c899911 to
f5d3503
Compare
|
Changes since v2:
|
…Y_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 FLAC 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.