Repository navigation
Conversation
The firmware cannot tell where the valid data ends in a compressed playback stream since the host DMA is free running around the buffer. The codec is fed with full input buffers and the end of stream is guessed from what follows the last valid byte: zeros if the stream fits into the buffer, stale data from the previous lap otherwise. With RAW AAC the stale data causes a fatal error and the drain never completes, with ADTS AAC the first frame which produces no output (oversized frame, resync) ends the stream early. Add a generic stream control parameter for compress modules: the host sends struct module_param records with 0xffff in the upper 16 bits of the id. SOF_COMPR_CTRL_STREAM_END carries the absolute byte offset of the end of the stream (the size of the stream), sent by the host on drain. In the Cadence module handle the stream controls without storing them as codec configuration and track the position in the input stream. When the stream end is known: - pass only the remaining bytes of the stream to the codec, the last input buffer can be partial - signal INPUT_OVER only when the last byte of the stream is passed - finish when the codec reports done or when the whole stream is consumed and no more output is produced Without the stream end the existing behavior is kept. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
ujfalusi
requested review from
dbaluta,
kv2019i,
lbetlej,
lgirdwood,
mmaka1 and
plbossart
as code owners
December 3, 2026 15:57
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
SOF_COMPR_CTRL_ID is expected to produce the host control ID 0xffff0001, but shifting signed 0xffff left by 16 produces a value not representable in a 32-bit signed int, invoking undefined behavior.
1 open issue
What changed in this PR
Updates SOF’s Cadence codec integration to use host-provided stream boundaries, avoiding drain failures and premature completion caused by padding or stale data.
Changes:
- Adds generic compressed-stream control parameters.
- Tracks input position and limits codec input to valid stream bytes.
- Uses the known boundary for end-of-stream handling while preserving legacy behavior when unavailable.
| File | Description |
|---|---|
src/include/sof/audio/module_adapter/module/compress_ctrl.h |
Defines stream-control IDs and helpers. |
src/include/sof/audio/module_adapter/module/cadence.h |
Adds stream-position and end-offset state. |
src/audio/module_adapter/module/cadence.c |
Updates input-over signaling and completion detection. |
src/audio/module_adapter/module/cadence_ipc4.c |
Handles controls, bounds input, tracks consumption, and resets stream state. |
Review effort: Balanced
| /* Absolute byte offset of the end of the stream (stream size), payload: uint64_t */ | ||
| #define SOF_COMPR_CTRL_STREAM_END 1 | ||
|
|
||
| #define SOF_COMPR_CTRL_PARAM_ID(ctrl) ((SOF_COMPR_CTRL_ID << 16) | (ctrl)) |
PR 11611: test resultsRun date: 2026-12-03 19:38 UTC Tested commit: e82ced73a15aa312089824a1a6c8d97eba67c212 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

The firmware cannot tell where the valid data ends in a compressed playback stream since the host DMA is free running around the buffer. The codec is fed with full input buffers and the end of stream is guessed from what follows the last valid byte: zeros if the stream fits into the buffer, stale data from the previous lap otherwise. With RAW AAC the stale data causes a fatal error and the drain never completes, with ADTS AAC the first frame which produces no output (oversized frame, resync) ends the stream early.
Add a generic stream control parameter for compress modules: the host sends struct module_param records with 0xffff in the upper 16 bits of the id. SOF_COMPR_CTRL_STREAM_END carries the absolute byte offset of the end of the stream (the size of the stream), sent by the host on drain.
In the Cadence module handle the stream controls without storing them as codec configuration and track the position in the input stream. When the stream end is known:
Without the stream end the existing behavior is kept.