Skip to content

audio: volume: use size_t for processing counts and unsigned channel counts - #11337

Open
softwarecki wants to merge 2 commits into
thesofproject:mainfrom
softwarecki:p20-volume
Open

softwarecki wants to merge 2 commits into
thesofproject:mainfrom
softwarecki:p20-volume

Conversation

@softwarecki

Copy link
Copy Markdown
Collaborator

Convert frame and sample counts to size_t across the processing implementations, and align the remaining channel counters with the unsigned stream channel count. Update the scalar unrolled loop bounds to avoid unsigned underflow.

Convert the remaining channel count and channel loop variables in the
ARM and RISC-V paths to unsigned int, aligning them with the generic
and HiFi implementations.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Widen the processing frame count and the per-chunk sample counters in all
format variants to size_t. The scalar unrolled loops use an addition based
bound instead of a subtraction so the unsigned counters cannot underflow.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused type conversions and loop-bound updates are consistent across implementations, with no blocking issues identified by static review; builds and tests were not run.

No open issues 🎉

What changed in this PR

This PR standardizes count types in SOF’s volume processing interface and backends, keeping callback signatures aligned and making scalar loop bounds safe for unsigned counts.

Changes:

  • Use size_t for frame parameters across all volume backends.
  • Convert ARM and RISC-V sample counts and indices to size_t, and channel counters to unsigned types.
  • Rewrite scalar unrolled loop bounds to avoid unsigned subtraction underflow.
File Description
src/​audio/​volume/​volume.h Updates the scaling callback’s frame-count type.
src/​audio/​volume/​volume.c Uses an unsigned channel count for alignment.
src/​audio/​volume/​volume_riscv.c Converts scalar counts and updates loop bounds.
src/​audio/​volume/​volume_riscv_with_peakvol.c Applies count and loop-bound changes to peak-meter processing.
src/​audio/​volume/​volume_hifi5.c Aligns HiFi5 frame parameters with the callback.
src/​audio/​volume/​volume_hifi5_with_peakvol.c Aligns HiFi5 peak-meter frame parameters.
src/​audio/​volume/​volume_hifi4.c Aligns HiFi4 frame parameters with the callback.
src/​audio/​volume/​volume_hifi4_with_peakvol.c Aligns HiFi4 peak-meter frame parameters.
src/​audio/​volume/​volume_hifi3.c Aligns HiFi3 frame parameters with the callback.
src/​audio/​volume/​volume_hifi3_with_peakvol.c Aligns HiFi3 peak-meter frame parameters.
src/​audio/​volume/​volume_generic.c Aligns generic frame parameters with the callback.
src/​audio/​volume/​volume_generic_with_peakvol.c Aligns generic peak-meter frame parameters.
src/​audio/​volume/​volume_arm.c Converts scalar counts and updates loop bounds.
src/​audio/​volume/​volume_arm_with_peakvol.c Applies count and loop-bound changes to peak-meter processing.

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants