Skip to content

Module: Audio: Add s16/32 source_get_data and sink_get_buffer - #10012

Merged
lgirdwood merged 2 commits into
thesofproject:mainfrom
singalsu:source_sink_api_add_s16_s32_get_data_func
May 30, 2025
Merged

Module: Audio: Add s16/32 source_get_data and sink_get_buffer#10012
lgirdwood merged 2 commits into
thesofproject:mainfrom
singalsu:source_sink_api_add_s16_s32_get_data_func

Conversation

@singalsu

Copy link
Copy Markdown
Collaborator

No description provided.

@singalsu
singalsuforce-pushed the source_sink_api_add_s16_s32_get_data_func branch from 815e093 to 51987d2CompareMay 16, 2025 09:39
@singalsu
singalsu marked this pull request as ready for review May 16, 2025 09:42
CopilotAI review requested due to automatic review settings May 16, 2025 09:42

CopilotAI 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.

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
FileDescription
src/module/audio/source_api.cAdded new s16 and s32 variants for source data retrieval using bit shifts.
src/module/audio/sink_api.cAdded new s16 and s32 variants for sink buffer retrieval using bit shifts.
src/include/module/audio/source_api.hUpdated header with new function prototypes and detailed API documentation.
src/include/module/audio/sink_api.hUpdated header with new function prototypes and detailed API documentation.
src/audio/template_comp/template-generic.cRefactored to use the new APIs and improved const-correctness in data pointers.

@singalsu

Copy link
Copy Markdown
CollaboratorAuthor

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

@marcinszkudlinskimarcinszkudlinski 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.

Nice helper

Comment threadsrc/module/audio/sink_api.c
Comment threadsrc/module/audio/sink_api.c
@singalsu
singalsuforce-pushed the source_sink_api_add_s16_s32_get_data_func branch from 51987d2 to 8b17b47CompareMay 21, 2025 12:14
@singalsu
singalsu requested a review from lyakhMay 21, 2025 12:14
Comment threadsrc/module/audio/sink_api.c Outdated

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

Copy link
Copy Markdown
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
Copy Markdown
CollaboratorAuthor

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>
@singalsu
singalsuforce-pushed the source_sink_api_add_s16_s32_get_data_func branch from 8b17b47 to 48f9f0bCompareMay 28, 2025 11:08
@singalsu
singalsu requested a review from lyakhMay 28, 2025 11:09
@lgirdwood
lgirdwood merged commit 250f17f into thesofproject:mainMay 30, 2025
Sign up for freeto 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.

5 participants

@singalsu@lyakh@lgirdwood@marcinszkudlinski