Skip to content

Conversation

@singalsu
Copy link
Collaborator

No description provided.

@singalsu singalsu force-pushed the source_sink_api_add_s16_s32_get_data_func branch from 815e093 to 51987d2 Compare May 16, 2025 09:39
@singalsu singalsu marked this pull request as ready for review May 16, 2025 09:42
Copilot AI review requested due to automatic review settings May 16, 2025 09:42
Copy link

Copilot AI left a 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.

@singalsu
Copy link
Collaborator Author

@marcinszkudlinski What do you think of this addition? I think it would simplify converting (most of) the modules to the new interface.

Copy link
Contributor

@marcinszkudlinski marcinszkudlinski left a comment

Choose a reason for hiding this comment

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

Nice helper

@singalsu singalsu force-pushed the source_sink_api_add_s16_s32_get_data_func branch from 51987d2 to 8b17b47 Compare May 21, 2025 12:14
@singalsu singalsu requested a review from lyakh May 21, 2025 12:14

ret = sink_get_buffer(sink, req_size, (void **)data_ptr, (void **)buffer_start,
&buffer_size);
if (!ret)
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

singalsu added 2 commits May 28, 2025 14:04
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>
@singalsu singalsu force-pushed the source_sink_api_add_s16_s32_get_data_func branch from 8b17b47 to 48f9f0b Compare May 28, 2025 11:08
@singalsu singalsu requested a review from lyakh May 28, 2025 11:09
@lgirdwood lgirdwood merged commit 250f17f into thesofproject:main May 30, 2025
42 of 48 checks passed
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.

4 participants