Module: Audio: Add s16/32 source_get_data and sink_get_buffer#10012
Merged
lgirdwood merged 2 commits intothesofproject:mainfrom May 30, 2025
Merged
Conversation
815e093 to
51987d2
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR adds new APIs for retrieving audio data and buffers in 16-bit and 32-bit sample formats, simplifying pointer arithmetic by returning the sample count instead of byte counts.
- Adds source_get_data_s16 and source_get_data_s32 in source_api.c along with corresponding EXPORT_SYMBOL declarations.
- Adds sink_get_buffer_s16 and sink_get_buffer_s32 in sink_api.c along with updated header documentation.
- Updates template components to use the new APIs and improve const-correctness in pointer handling.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/module/audio/source_api.c | Added new s16 and s32 variants for source data retrieval using bit shifts. |
| src/module/audio/sink_api.c | Added new s16 and s32 variants for sink buffer retrieval using bit shifts. |
| src/include/module/audio/source_api.h | Updated header with new function prototypes and detailed API documentation. |
| src/include/module/audio/sink_api.h | Updated header with new function prototypes and detailed API documentation. |
| src/audio/template_comp/template-generic.c | Refactored to use the new APIs and improved const-correctness in data pointers. |
Collaborator
Author
|
@marcinszkudlinski What do you think of this addition? I think it would simplify converting (most of) the modules to the new interface. |
lgirdwood
approved these changes
May 19, 2025
lyakh
reviewed
May 20, 2025
51987d2 to
8b17b47
Compare
lyakh
requested changes
May 22, 2025
src/module/audio/sink_api.c
Outdated
|
|
||
| ret = sink_get_buffer(sink, req_size, (void **)data_ptr, (void **)buffer_start, | ||
| &buffer_size); | ||
| if (!ret) |
Collaborator
There was a problem hiding this comment.
ouch... shouldn't this be the other way round?
Collaborator
Author
There was a problem hiding this comment.
Oops, yes. It stopped working with the control enabled... I should never push a patch blindly without local test. It's fixed in this push.
This patch adds helper functions source_get_data_s16(), source_get_data_s32(), sink_get_buffer_s16(), and sink_get_buffer_s32(). The buffer_samples as number of samples simplifies the processing function with no division or shift needed to convert buffer size in bytes to samples. Also the int16_t and int32_t typed arguments for data pointer and buffer start avoid type casts in a typical simple processing function. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This patch modifies the template component to use in process functions the source_get_data_s16/32() and sink_get_buffer_s16/32() functions. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
8b17b47 to
48f9f0b
Compare
lyakh
approved these changes
May 30, 2025
lgirdwood
approved these changes
May 30, 2025
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.
No description provided.