smart_amp_test: fix crash due to different source formats #9020
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.
This patch fixes a rare crash while testing multiple-pause-resume.sh described in #8651
Explanation:
Dai copier sends data to smart_amp in lnl nocodec. Smart_amp_test uses a process function to just copy buffer contents from sources to sink. The bind between those two uses a 16bit format buffer, while other smart amp pins use 32bit. Smart_amp_test in .prepare function chooses a process callback based only on the format of the sink. This way a 32bit process function is chosen, despite one of the sources being 16bit which risks misalignment. Crash is pretty rare because the misalignment only happens when dai_copier outputs one sample less (an odd number), probably due to stress.
Pushing one of the possible fixes here, but there are other options I can write and push if you want:
- Choose 32bit only when all the sinks and sources are 32bit, else use 16bit process (I pushed this one)
- Create a new process function that always copies word by word, and copies the misaligned data that remains byte by byte. Remove the other process functions.
- Ignore the optimization and just always use process_s16 to be safe