audio: introduce and use source_cir_buf_wrap for const source reads - #11170
Open
softwarecki wants to merge 7 commits into
Open
audio: introduce and use source_cir_buf_wrap for const source reads#11170softwarecki wants to merge 7 commits into
softwarecki wants to merge 7 commits into
Conversation
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>
softwarecki
requested review from
abonislawski,
kv2019i,
lyakh,
piotrhoppeintel,
serhiy-katsyuba-intel,
tmleman and
wjablon1
and
a lite review from Copilot
September 4, 2026 14:32
softwarecki
requested review from
a team,
dbaluta,
lbetlej,
lgirdwood,
mmaka1 and
plbossart
as code owners
September 4, 2026 14:32
Contributor
There was a problem hiding this comment.
🟢 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()inaudio_stream.hto support const source pointer wrapping. - Replace source-side uses of
cir_buf_wrap()withsource_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) |
PR 11170: test resultsRun date: 2026-09-04 14:55 UTC Tested commit: 59b1f1b558a855df87f7f18614c02a04f1e064d4 |
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.
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.