Skip to content

audio: introduce and use source_cir_buf_wrap for const source reads - #11170

Open
softwarecki wants to merge 7 commits into
thesofproject:mainfrom
softwarecki:source_cir_buf_wrap
Open

audio: introduce and use source_cir_buf_wrap for const source reads#11170
softwarecki wants to merge 7 commits into
thesofproject:mainfrom
softwarecki:source_cir_buf_wrap

Conversation

@softwarecki

Copy link
Copy Markdown
Collaborator

Adds a const-correct forward-wrap helper for read-only circular buffers and uses it on the source (read) side across the audio components, so source read pointers can wrap without casting away const. Also constifies the dcblock HiFi read paths that previously stripped const via casts.

Add const-correct helper function for read-only circular buffers. It takes
and returns a const pointer so source read paths can wrap without casting
away const.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Use the source_cir_buf_wrap() function to wrap the const source read
pointer instead of cir_buf_wrap() to preserve const.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Use the source_cir_buf_wrap() function to wrap the const source read
pointer instead of cir_buf_wrap() to avoid discarding const.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Use the source_cir_buf_wrap() function to wrap the const source read
pointer instead of cir_buf_wrap() to avoid discarding const.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Use the source_cir_buf_wrap() function to wrap the const read pointer
in the HiFi5 cir_buf_copy() with source_cir_buf_wrap() instead of
cir_buf_wrap() to preserve const.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Use the source_cir_buf_wrap() function to wrap the const source read
pointer instead of cir_buf_wrap() across the generic and HiFi3/4/5 paths.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Declare source-side pointers as const and remove const-stripping casts in
HiFi3 and HiFi4 implementations.

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 changes are const-correct, mechanical substitutions of wrap helpers with no apparent behavioral changes beyond removing const-stripping casts.

Pull request overview

This PR introduces source_cir_buf_wrap() (a const-correct forward wrap helper for circular buffers) and updates multiple audio components to use it on the source/read side, eliminating prior const-stripping casts and tightening const-correctness in dcblock HiFi paths.

Changes:

  • Add source_cir_buf_wrap() in audio_stream.h to support const source pointer wrapping.
  • Replace source-side uses of cir_buf_wrap() with source_cir_buf_wrap() across volume, PCM converter, ASRC, dcblock, and component copy paths.
  • Constify dcblock HiFi3/HiFi4 source pointer handling and circular-buffer setup parameters.
File summaries
File Description
src/include/module/audio/audio_stream.h Adds const-correct forward wrap helper for source/read pointers.
src/audio/volume/volume.c Switches source-side wrap operations to the const helper.
src/audio/volume/volume_hifi5.c Uses const helper for wrapping HiFi5 source pointers.
src/audio/volume/volume_hifi5_with_peakvol.c Uses const helper for wrapping HiFi5+peakvol source pointers.
src/audio/volume/volume_hifi4.c Uses const helper for wrapping HiFi4 source pointers.
src/audio/volume/volume_hifi4_with_peakvol.c Uses const helper for wrapping HiFi4+peakvol source pointers.
src/audio/volume/volume_hifi3.c Uses const helper for wrapping HiFi3 source pointers.
src/audio/volume/volume_generic.c Uses const helper for wrapping generic source pointers.
src/audio/volume/volume_generic_with_peakvol.c Uses const helper for wrapping generic+peakvol source pointers.
src/audio/pcm_converter/pcm_remap.c Uses const helper for wrapping remap source pointers.
src/audio/pcm_converter/pcm_converter.c Uses const helper for wrapping linear-convert read pointer.
src/audio/pcm_converter/pcm_converter_hifi3.c Uses const helper for wrapping HiFi3 converter source pointers.
src/audio/pcm_converter/pcm_converter_generic.c Uses const helper for wrapping generic converter source pointers.
src/audio/dcblock/dcblock_hifi4.c Constifies dcblock HiFi4 source pointers and circular-buffer setup args.
src/audio/dcblock/dcblock_hifi3.c Constifies dcblock HiFi3 source pointers and circular-buffer setup args.
src/audio/dcblock/dcblock_generic.c Uses const helper for wrapping generic dcblock source pointers.
src/audio/component.c Uses const helper in circular-buffer copy for the input pointer wrap.
src/audio/asrc/asrc.c Uses const helper for wrapping ASRC source pointers during copy-in.
Review details
  • Files reviewed: 18/18 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +187 to +196
/**
* Verifies a read pointer and performs rollover when reached the end of the circular buffer.
* @param ptr Pointer
* @param buf_addr Start address of the circular buffer.
* @param buf_end End address of the circular buffer.
* @return Pointer, adjusted if necessary.
*/

static inline const void *source_cir_buf_wrap(const void *ptr, const void *buf_addr,
const void *buf_end)
@intel-sofci

Copy link
Copy Markdown

PR 11170: test results

Run date: 2026-09-04 14:55 UTC

Tested commit: 59b1f1b558a855df87f7f18614c02a04f1e064d4

mtl pass rate lnl pass rate ptl pass rate wcl pass rate nvl pass rate

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.

3 participants