-
Notifications
You must be signed in to change notification settings - Fork 349
Module: Audio: Add s16/32 source_get_data and sink_get_buffer #10012
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Module: Audio: Add s16/32 source_get_data and sink_get_buffer #10012
Conversation
815e093 to
51987d2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
|
@marcinszkudlinski What do you think of this addition? I think it would simplify converting (most of) the modules to the new interface. |
marcinszkudlinski
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice helper
51987d2 to
8b17b47
Compare
src/module/audio/sink_api.c
Outdated
|
|
||
| ret = sink_get_buffer(sink, req_size, (void **)data_ptr, (void **)buffer_start, | ||
| &buffer_size); | ||
| if (!ret) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ouch... shouldn't this be the other way round?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
No description provided.