module: waves: rework module to use sink/source api#10790
Open
softwarecki wants to merge 1 commit into
Open
Conversation
Rework the waves module to only use the sink/source api to prepare sof for the full transition to pipeline 2.0. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
serhiy-katsyuba-intel
approved these changes
May 18, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Reworks the WAVES module adapter processing path to use the sink/source API (ring-buffer based) instead of the legacy raw input/output buffer API, aligning the module with the pipeline 2.0 transition.
Changes:
- Switch
waves_codec_process()to the sink/sourceprocesscallback signature. - Read input via
source_get_data()(with wrap handling) into the module’s internal input buffer. - Write output via
sink_get_buffer()+sink_commit_buffer()(with wrap handling) from the module’s internal output buffer.
Comments suppressed due to low confidence (3)
src/audio/module_adapter/module/waves/waves.c:766
source_get_data()expectsvoid const **buffer_start, butsrc_buf_startis declared asvoid *and passed by address, which is an incompatible pointer type and can trigger build warnings/errors. Declaresrc_buf_startasconst void *(oruint8_t const *) and keep the pointer types consistent withsource_api.h.
const void *src_ptr;
void *src_buf_start;
size_t src_buf_size;
src/audio/module_adapter/module/waves/waves.c:796
- Input is released from the source (
source_release_data(..., n_bytes)) immediately after copying, beforeMaxxEffect_Process()and before ensuring the output can be written. If processing fails orsink_get_buffer()returns an error, the input has already been consumed and will be lost (previous legacy path keptconsumed=0on errors). Delay releasing the source until after successful processing/output commit, and on failure paths release 0 bytes to drop the reservation without consuming.
ret = source_get_data(sources[0], n_bytes, &src_ptr, &src_buf_start, &src_buf_size);
if (ret)
return ret;
/* src_buf_size is the total ring buffer size; handle wrap when copying to in_buff */
size_to_wrap = (const uint8_t *)src_buf_start + src_buf_size - (const uint8_t *)src_ptr;
if (n_bytes <= size_to_wrap) {
memcpy_s(codec->mpd.in_buff, n_bytes, src_ptr, n_bytes);
} else {
memcpy_s(codec->mpd.in_buff, n_bytes, src_ptr, size_to_wrap);
memcpy_s((uint8_t *)codec->mpd.in_buff + size_to_wrap, n_bytes - size_to_wrap,
src_buf_start, n_bytes - size_to_wrap);
}
source_release_data(sources[0], n_bytes);
codec->mpd.avail = n_bytes;
src/audio/module_adapter/module/waves/waves.c:836
- There is no check that the sink has enough free space before running the effect, and
sink_get_buffer()errors are handled after the input has already been released. If the sink is full, this can cause dropped samples or re-processing on retry (depending on how source release is fixed). Add an earlysink_get_free_size()check (e.g., againstcodec->mpd.out_buff_size/expected produced bytes) and return-ENOSPCwithout consuming input when there isn’t enough space.
codec->mpd.produced = waves_codec->o_stream.numAvailableSamples *
waves_codec->o_format.numChannels * waves_codec->sample_size_in_bytes;
codec->mpd.consumed = codec->mpd.produced;
ret = sink_get_buffer(sinks[0], codec->mpd.produced,
&snk_ptr, &snk_buf_start, &snk_buf_size);
if (!ret) {
Comment on lines
+756
to
+758
| static int waves_codec_process(struct processing_module *mod, | ||
| struct sof_source **sources, int num_of_sources, | ||
| struct sof_sink **sinks, int num_of_sinks) |
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.
Rework the waves module to only use the sink/source api to prepare sof for the full transition to pipeline 2.0.