From 07815d222cba789570f3033b3f744bd342d00b7e Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Wed, 15 Apr 2026 14:10:22 +0300 Subject: [PATCH 1/6] Audio: Audio Stream: Add function to calculate aligned number of frames This patch adds to audio_stream.h inline functions: - audio_stream_align_frames_round_down() - audio_stream_align_frames_round_up() - audio_stream_align_frames_round_nearest() They are useful when an algorithm needs to process a number of frames that is smaller then data size than offered by module API. E.g. when volume component ramps the volume, the block with same gain is smaller than a normal processing period. Signed-off-by: Seppo Ingalsuo --- src/include/sof/audio/audio_stream.h | 46 ++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/include/sof/audio/audio_stream.h b/src/include/sof/audio/audio_stream.h index 9703ec9cadea..abf9f7d947bd 100644 --- a/src/include/sof/audio/audio_stream.h +++ b/src/include/sof/audio/audio_stream.h @@ -612,6 +612,52 @@ audio_stream_avail_frames_aligned(const struct audio_stream *source, return MIN(src_frames, sink_frames); } +/** + * Rounds down a frame count to meet the alignment constraint of the stream. + * @param stream Audio stream with alignment requirements set. + * @param frames Frame count to round down. + * @return Largest aligned frame count less than or equal to frames. + */ +static inline uint32_t audio_stream_align_frames_round_down(const struct audio_stream *stream, + uint32_t frames) +{ + uint16_t align = stream->runtime_stream_params.align_frame_cnt; + + return ROUND_DOWN(frames, align); +} + +/** + * Rounds up a frame count to meet the alignment constraint of the stream. + * @param stream Audio stream with alignment requirements set. + * @param frames Frame count to round up. + * @return Smallest aligned frame count greater than or equal to frames. + */ +static inline uint32_t audio_stream_align_frames_round_up(const struct audio_stream *stream, + uint32_t frames) +{ + uint16_t align = stream->runtime_stream_params.align_frame_cnt; + uint32_t aligned_frames = ROUND_DOWN(frames, align); + + if (aligned_frames < frames) + aligned_frames += align; + + return aligned_frames; +} + +/** + * Rounds to nearest a frame count to meet the alignment constraint of the stream. + * @param stream Audio stream with alignment requirements set. + * @param frames Frame count to round to nearest. + * @return Aligned frame count. + */ +static inline uint32_t audio_stream_align_frames_round_nearest(const struct audio_stream *stream, + uint32_t frames) +{ + uint16_t align = stream->runtime_stream_params.align_frame_cnt; + + return ROUND_DOWN(frames + (align >> 1), align); +} + /** * Updates the buffer state after writing to the buffer. * @param buffer Buffer to update. From 531c255c9608db73de2a7c2fe94971ad8363ca38 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Wed, 15 Apr 2026 14:31:42 +0300 Subject: [PATCH 2/6] Audio: Volume: Fix the ramping and ZC mode align This patch fixes an issue where processing smaller parts of the period can break the data align constraints. The frames count value from zc_get() function or from cd->vol_ramp_frames is rounded up to next align compatible frames count. The failure with align constraints appeared as glitches in audio with some 44.1 kHz family sample rates. Signed-off-by: Seppo Ingalsuo --- src/audio/volume/volume.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/audio/volume/volume.c b/src/audio/volume/volume.c index aed356a3ec83..0dd34e200429 100644 --- a/src/audio/volume/volume.c +++ b/src/audio/volume/volume.c @@ -556,6 +556,7 @@ static int volume_process(struct processing_module *mod, struct output_stream_buffer *output_buffers, int num_output_buffers) { struct vol_data *cd = module_get_private_data(mod); + struct audio_stream *source = input_buffers[0].data; uint32_t avail_frames = input_buffers[0].size; uint32_t frames; int64_t prev_sum = 0; @@ -571,12 +572,27 @@ static int volume_process(struct processing_module *mod, frames = avail_frames; } else if (cd->ramp_type == SOF_VOLUME_LINEAR_ZC) { /* with ZC ramping look for next ZC offset */ - frames = cd->zc_get(input_buffers[0].data, cd->vol_ramp_frames, &prev_sum); + frames = cd->zc_get(source, cd->vol_ramp_frames, &prev_sum); + /* Align frames count to audio stream constraints. If it rounds to zero + * round it up to smallest nonzero aligned frames count. + */ + frames = audio_stream_align_frames_round_nearest(source, frames); + if (!frames) + frames = audio_stream_align_frames_round_up(source, 1); } else { - /* without ZC process max ramp chunk */ - frames = cd->vol_ramp_frames; + /* During volume ramp align the number of frames used in this + * gain step. Align up since with low rates this would typically + * become zero. + */ + frames = audio_stream_align_frames_round_up(source, cd->vol_ramp_frames); } + /* Cancel the gain step for ZC or smaller ramp step if it exceeds + * the available frames. + */ + if (frames > avail_frames) + frames = avail_frames; + if (!cd->ramp_finished) { volume_ramp(mod); cd->vol_ramp_elapsed_frames += frames; From ab79b4edf721b2f0c2ce91a3734db8d67389ef8a Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Tue, 21 Apr 2026 18:31:08 +0300 Subject: [PATCH 3/6] Audio: Volume: Set align constraints for source only This patch modifies the frame align request to match the gain loop samples unroll number. In HiFi5 four s32 samples or eight s16 are processed per iteration. In HiFi3, HiFi4 and generic C two s32 samples or four s16 samples are processed per iteration. The equation frame_align_req = n / gcd(n, channels) with n = 8 or n = 4 for HiFi5 for s16 or s32 n = 4 or 4 = 2 for other builds for s16 or s32 ensures that every aligned frame count is multiple of gain loop unroll amount. The equation for byte_align is same as earlier but the unnecessary SOF_USE_HIFI() are removed. The code wasn't wrong for HiFi5 but it was confusing. The check for 6ch wasn't done because the SOF_FRAME_BYTE_ALIGN value was the same as VOLUME_HIFI3_HIFI4_FRAME_BYTE_ALIGN_6CH. Signed-off-by: Seppo Ingalsuo --- src/audio/volume/volume.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/src/audio/volume/volume.c b/src/audio/volume/volume.c index 0dd34e200429..a6cff8a09083 100644 --- a/src/audio/volume/volume.c +++ b/src/audio/volume/volume.c @@ -639,30 +639,37 @@ static vol_zc_func vol_get_zc_function(struct comp_dev *dev, /** * \brief Set volume frames alignment limit. * \param[in,out] source Structure pointer of source. - * \param[in,out] sink Structure pointer of sink. */ -static void volume_set_alignment(struct audio_stream *source, - struct audio_stream *sink) +static void volume_set_alignment(struct audio_stream *source) { - /* Both source and sink buffer in HiFi5 processing version, - * xtensa intrinsics ask for 16-byte aligned. + const int channels = audio_stream_get_channels(source); + + /* The source buffer in HiFi5 processing version needs 16 bytes alignment. The + * macro SOF_FRAME_BYTE_ALIGN is set in common.h to the requirement align. + * The VOLUME_HIFI3_HIFI4_FRAME_BYTE_ALIGN_6CH also has the value 16 and the + * same align for 5.1 channels works for HiFi5 too. * - * Both source and sink buffer in HiFi3 or HiFi4 processing version, - * xtensa intrinsics ask for 8-byte aligned. 5.1 format SSE audio - * requires 16-byte aligned. + * In HiFi4 processing version the source align requirement is 8 bytes. While + * the 5.1 format SSE audio requires 16 bytes alignment. + */ + const uint32_t byte_align = + (channels == 6) ? VOLUME_HIFI3_HIFI4_FRAME_BYTE_ALIGN_6CH : SOF_FRAME_BYTE_ALIGN; + + /* On HiFi5 the number of samples to process must be multiple of four for s24/s32 + * and multiple of eight for s16. For HiFi4 and HiFi3 the number of samples + * need to be multiple of two for s32 and multiple of four for s16. + * E.g. for s32 format for channels counts of 1, 2, 4, 6, ... the + * frame align need to be 4, 2, 1, 2, ... */ -#if SOF_USE_HIFI(3, VOLUME) || SOF_USE_HIFI(4, VOLUME) - const uint32_t byte_align = audio_stream_get_channels(source) == 6 ? - VOLUME_HIFI3_HIFI4_FRAME_BYTE_ALIGN_6CH : SOF_FRAME_BYTE_ALIGN; +#if SOF_USE_HIFI(5, VOLUME) + const int n = (audio_stream_get_valid_fmt(source) == SOF_IPC_FRAME_S16_LE) ? 8 : 4; #else - const uint32_t byte_align = SOF_FRAME_BYTE_ALIGN; + const int n = (audio_stream_get_valid_fmt(source) == SOF_IPC_FRAME_S16_LE) ? 4 : 2; #endif - /*There is no limit for frame number, so both source and sink set it to be 1*/ - const uint32_t frame_align_req = 1; + const uint32_t frame_align_req = (uint32_t)(n / gcd(n, channels)); audio_stream_set_align(byte_align, frame_align_req, source); - audio_stream_set_align(byte_align, frame_align_req, sink); } /** @@ -698,7 +705,7 @@ static int volume_prepare(struct processing_module *mod, ret = volume_peak_prepare(cd, mod); - volume_set_alignment(&sourceb->stream, &sinkb->stream); + volume_set_alignment(&sourceb->stream); /* get sink period bytes */ sink_period_bytes = audio_stream_period_bytes(&sinkb->stream, From 20c06c4012a399907c74f7ed18ea54b22659adc0 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Tue, 21 Apr 2026 14:19:43 +0300 Subject: [PATCH 4/6] Audio: Set default audio stream align to SOF_FRAME_BYTE_ALIGN This patch changes the default align from 1 bytes to SOF_FRAME_BYTE_ALIGN that depends on build architecture. It defaults to 4 in generic build and to values 8 and 16 for Hifi3/4 and HiFi5 builds. A macro is defined for frame count align value 1 with name SOF_FRAME_COUNT_ALIGN. It can be used instead of numeric value 1. Modules can use it when there is no specific requirement for frames count constraint. Signed-off-by: Seppo Ingalsuo --- src/audio/audio_stream.c | 2 +- src/include/sof/common.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/audio/audio_stream.c b/src/audio/audio_stream.c index c4c5f7b04acb..aa16617f066c 100644 --- a/src/audio/audio_stream.c +++ b/src/audio/audio_stream.c @@ -51,6 +51,6 @@ void audio_stream_init(struct audio_stream *audio_stream, void *buff_addr, uint3 audio_stream->addr = buff_addr; audio_stream->end_addr = (char *)audio_stream->addr + size; - audio_stream_set_align(1, 1, audio_stream); + audio_stream_set_align(SOF_FRAME_BYTE_ALIGN, SOF_FRAME_COUNT_ALIGN, audio_stream); audio_stream_reset(audio_stream); } diff --git a/src/include/sof/common.h b/src/include/sof/common.h index 4bb279b039aa..d7aa9a7989cb 100644 --- a/src/include/sof/common.h +++ b/src/include/sof/common.h @@ -223,6 +223,9 @@ # define SOF_FRAME_BYTE_ALIGN 4 #endif +/* Default frame-count alignment is 1 */ +#define SOF_FRAME_COUNT_ALIGN 1 + #ifndef __GLIBC_USE #define __GLIBC_USE(x) 0 #endif From 2427f43436165ac75e5ecfb30d2eb5c65ea84846 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Tue, 21 Apr 2026 14:26:49 +0300 Subject: [PATCH 5/6] Audio: Modify audio_stream_avail_frames_aligned() to align for source This change fixes an issue that is caused by the logic in the function that calculates the aligned frames counts separately for source and sink and then returns the smaller number of them. The fixed logic checks the maximum number of frames that could be processed from source to sink and adjusts the the number down with source align constraints. It prevents an issue where a downstream module in pipeline modifies align constraint for it's source that is previous module's sink. A more relaxed constraint could then break source align criteria if the number of frames to process is limited by sink. The proposed logic for align follows only source align criteria to avoid conflicting constraints. Signed-off-by: Seppo Ingalsuo --- src/include/sof/audio/audio_stream.h | 41 +++++++++++++--------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/src/include/sof/audio/audio_stream.h b/src/include/sof/audio/audio_stream.h index abf9f7d947bd..dd81c157b8d8 100644 --- a/src/include/sof/audio/audio_stream.h +++ b/src/include/sof/audio/audio_stream.h @@ -590,28 +590,6 @@ audio_stream_avail_frames(const struct audio_stream *source, return MIN(src_frames, sink_frames); } -/** - * Computes maximum number of frames aligned that can be copied from - * source buffer to sink buffer, verifying number of available source - * frames vs. free space available in sink. - * @param source Buffer of source. - * @param sink Buffer of sink. - * @return Number of frames. - */ -static inline uint32_t -audio_stream_avail_frames_aligned(const struct audio_stream *source, - const struct audio_stream *sink) -{ - uint32_t src_frames = (audio_stream_get_avail_bytes(source) >> - source->runtime_stream_params.align_shift_idx) * - source->runtime_stream_params.align_frame_cnt; - uint32_t sink_frames = (audio_stream_get_free_bytes(sink) >> - sink->runtime_stream_params.align_shift_idx) * - sink->runtime_stream_params.align_frame_cnt; - - return MIN(src_frames, sink_frames); -} - /** * Rounds down a frame count to meet the alignment constraint of the stream. * @param stream Audio stream with alignment requirements set. @@ -658,6 +636,25 @@ static inline uint32_t audio_stream_align_frames_round_nearest(const struct audi return ROUND_DOWN(frames + (align >> 1), align); } +/** + * Computes maximum number of frames aligned with source align criteria + * that can be copied from source buffer to sink buffer, verifying number + * of available source frames vs. free space available in sink. + * @param source Buffer of source. + * @param sink Buffer of sink. + * @return Number of frames. + */ +static inline uint32_t +audio_stream_avail_frames_aligned(const struct audio_stream *source, + const struct audio_stream *sink) +{ + uint32_t src_frames = audio_stream_get_avail_frames(source); + uint32_t sink_frames = audio_stream_get_free_frames(sink); + uint32_t n = MIN(src_frames, sink_frames); + + return audio_stream_align_frames_round_down(source, n); +} + /** * Updates the buffer state after writing to the buffer. * @param buffer Buffer to update. From 40eac587bf874cbb86074286ab1d19cb58959570 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Tue, 21 Apr 2026 14:34:53 +0300 Subject: [PATCH 6/6] Audio: Do not set sink align constraints in modules and use default This patch mofidies modules ARIA, EQFIR, EQIIR, IGO NR, Mixer, Selector, SRC, and TDFB by removing sink align constraints set. Also the frame byte align of 1 is changed to SOF_FRAME_BYTE_ALIGN. When the sink align is not set the default values from audio_stream_init() is used, or the downstream modules sets the align for the source. Signed-off-by: Seppo Ingalsuo --- src/audio/aria/aria.c | 6 +----- src/audio/eq_fir/eq_fir.c | 8 +++----- src/audio/eq_iir/eq_iir.c | 2 +- src/audio/igo_nr/igo_nr.c | 3 +-- src/audio/mixer/mixer.c | 17 ++++++++++------- src/audio/mixer/mixer.h | 3 +++ src/audio/selector/selector.c | 3 +-- src/audio/src/src_common.c | 7 +++---- src/audio/src/src_common.h | 2 +- src/audio/src/src_ipc3.c | 2 +- src/audio/src/src_ipc4.c | 2 +- src/audio/tdfb/tdfb.c | 8 +++----- 12 files changed, 29 insertions(+), 34 deletions(-) diff --git a/src/audio/aria/aria.c b/src/audio/aria/aria.c index 0c9ffee5dd39..dc265cfac240 100644 --- a/src/audio/aria/aria.c +++ b/src/audio/aria/aria.c @@ -168,11 +168,6 @@ static void aria_set_stream_params(struct comp_buffer *buffer, const struct ipc4_audio_format *audio_fmt = &mod->priv.cfg.base_cfg.audio_fmt; ipc4_update_buffer_format(buffer, audio_fmt); -#if SOF_USE_HIFI(3, ARIA) || SOF_USE_HIFI(4, ARIA) - audio_stream_set_align(8, 1, &buffer->stream); -#elif SOF_USE_HIFI(5, ARIA) - audio_stream_set_align(16, 1, &buffer->stream); -#endif } static int aria_prepare(struct processing_module *mod, @@ -195,6 +190,7 @@ static int aria_prepare(struct processing_module *mod, aria_set_stream_params(source, mod); aria_set_stream_params(sink, mod); + audio_stream_set_align(SOF_FRAME_BYTE_ALIGN, SOF_FRAME_COUNT_ALIGN, &source->stream); if (audio_stream_get_valid_fmt(&source->stream) != SOF_IPC_FRAME_S24_4LE || audio_stream_get_valid_fmt(&sink->stream) != SOF_IPC_FRAME_S24_4LE) { diff --git a/src/audio/eq_fir/eq_fir.c b/src/audio/eq_fir/eq_fir.c index 39cce7fd7974..793a2294c647 100644 --- a/src/audio/eq_fir/eq_fir.c +++ b/src/audio/eq_fir/eq_fir.c @@ -366,14 +366,12 @@ static int eq_fir_process(struct processing_module *mod, return 0; } -static void eq_fir_set_alignment(struct audio_stream *source, - struct audio_stream *sink) +static void eq_fir_set_alignment(struct audio_stream *source) { - const uint32_t byte_align = 1; + const uint32_t byte_align = SOF_FRAME_BYTE_ALIGN; const uint32_t frame_align_req = 2; /* Process multiples of 2 frames */ audio_stream_set_align(byte_align, frame_align_req, source); - audio_stream_set_align(byte_align, frame_align_req, sink); } static int eq_fir_prepare(struct processing_module *mod, @@ -404,7 +402,7 @@ static int eq_fir_prepare(struct processing_module *mod, return ret; } - eq_fir_set_alignment(&sourceb->stream, &sinkb->stream); + eq_fir_set_alignment(&sourceb->stream); channels = audio_stream_get_channels(&sinkb->stream); frame_fmt = audio_stream_get_frm_fmt(&sourceb->stream); diff --git a/src/audio/eq_iir/eq_iir.c b/src/audio/eq_iir/eq_iir.c index 0f07fbeda03c..016c2c8caf82 100644 --- a/src/audio/eq_iir/eq_iir.c +++ b/src/audio/eq_iir/eq_iir.c @@ -142,7 +142,7 @@ static int eq_iir_process(struct processing_module *mod, static void eq_iir_set_alignment(struct audio_stream *source, struct audio_stream *sink) { - const uint32_t byte_align = 8; + const uint32_t byte_align = SOF_FRAME_BYTE_ALIGN; const uint32_t frame_align_req = 2; audio_stream_set_align(byte_align, frame_align_req, source); diff --git a/src/audio/igo_nr/igo_nr.c b/src/audio/igo_nr/igo_nr.c index bde7d2b8fe32..e398af7d964b 100644 --- a/src/audio/igo_nr/igo_nr.c +++ b/src/audio/igo_nr/igo_nr.c @@ -832,8 +832,7 @@ static int32_t igo_nr_prepare(struct processing_module *mod, if (ret) return ret; - source_set_alignment_constants(source, 1, IGO_FRAME_SIZE); - sink_set_alignment_constants(sink, 1, IGO_FRAME_SIZE); + source_set_alignment_constants(source, SOF_FRAME_BYTE_ALIGN, IGO_FRAME_SIZE); igo_nr_set_igo_params(mod); diff --git a/src/audio/mixer/mixer.c b/src/audio/mixer/mixer.c index 6300d5b86bc5..26023bb6a570 100644 --- a/src/audio/mixer/mixer.c +++ b/src/audio/mixer/mixer.c @@ -187,18 +187,18 @@ static int mixer_reset(struct processing_module *mod) /* init and calculate the aligned setting for available frames and free frames retrieve*/ static inline void mixer_set_frame_alignment(struct audio_stream *source) { -#if XCHAL_HAVE_HIFI3 || XCHAL_HAVE_HIFI4 /* Xtensa intrinsics ask for 8-byte aligned. 5.1 format SSE audio - * requires 16-byte aligned. + * requires 16-byte aligned. Note: The SOF_FRAME_BYTE_ALIGN is the + * same value 16 with HiFi5. */ - const uint32_t byte_align = audio_stream_get_channels(source) == 6 ? 16 : 8; + const uint32_t byte_align = audio_stream_get_channels(source) == 6 ? + MIXER_HIFI_FRAME_BYTE_ALIGN_6CH : SOF_FRAME_BYTE_ALIGN; - /*There is no limit for frame number, so set it as 1*/ - const uint32_t frame_align_req = 1; + /* There is no limit for frame number, so set it as default (1). */ + const uint32_t frame_align_req = SOF_FRAME_COUNT_ALIGN; audio_stream_set_align(byte_align, frame_align_req, source); -#endif } static int mixer_prepare(struct processing_module *mod, @@ -216,7 +216,10 @@ static int mixer_prepare(struct processing_module *mod, } md->mix_func = mixer_get_processing_function(dev, sink); - mixer_set_frame_alignment(&sink->stream); + + /* No need to set sink align constraints, set constraints for each + * source next. The sink align will follow to common source alignment. + */ /* check each mixer source state */ struct comp_buffer *source; diff --git a/src/audio/mixer/mixer.h b/src/audio/mixer/mixer.h index 118aaf1c914f..875ddcbb26fe 100644 --- a/src/audio/mixer/mixer.h +++ b/src/audio/mixer/mixer.h @@ -32,6 +32,9 @@ void sys_comp_module_mixer_interface_init(void); #define MIXER_MAX_SOURCES 2 +/* Xtensa HiFi optimized version needs this for 5.1ch */ +#define MIXER_HIFI_FRAME_BYTE_ALIGN_6CH 16 + /* mixer component private data */ struct mixer_data { void (*mix_func)(struct comp_dev *dev, struct audio_stream *sink, diff --git a/src/audio/selector/selector.c b/src/audio/selector/selector.c index 8d99d785a899..6afc92d8bdfc 100644 --- a/src/audio/selector/selector.c +++ b/src/audio/selector/selector.c @@ -1007,8 +1007,7 @@ static int selector_prepare(struct processing_module *mod, sourceb = comp_dev_get_first_data_producer(dev); sinkb = comp_dev_get_first_data_consumer(dev); - audio_stream_set_align(4, 1, &sourceb->stream); - audio_stream_set_align(4, 1, &sinkb->stream); + audio_stream_set_align(SOF_FRAME_BYTE_ALIGN, SOF_FRAME_COUNT_ALIGN, &sourceb->stream); /* get source data format and period bytes */ cd->source_format = audio_stream_get_frm_fmt(&sourceb->stream); diff --git a/src/audio/src/src_common.c b/src/audio/src/src_common.c index cb595f3e8877..3a9c7dac280f 100644 --- a/src/audio/src/src_common.c +++ b/src/audio/src/src_common.c @@ -384,13 +384,12 @@ int src_copy_sxx(struct comp_data *cd, struct sof_source *source, return -ENOTSUP; } -void src_set_alignment(struct sof_source *source, struct sof_sink *sink) +void src_set_alignment(struct sof_source *source) { - const uint32_t byte_align = 1; - const uint32_t frame_align_req = 1; + const uint32_t byte_align = SOF_FRAME_BYTE_ALIGN; + const uint32_t frame_align_req = SOF_FRAME_COUNT_ALIGN; source_set_alignment_constants(source, byte_align, frame_align_req); - sink_set_alignment_constants(sink, byte_align, frame_align_req); } static int src_verify_params(struct processing_module *mod) diff --git a/src/audio/src/src_common.h b/src/audio/src/src_common.h index ae3c60574eec..98f29a263131 100644 --- a/src/audio/src/src_common.h +++ b/src/audio/src/src_common.h @@ -143,7 +143,7 @@ int32_t src_input_rates(void); int32_t src_output_rates(void); -void src_set_alignment(struct sof_source *source, struct sof_sink *sink); +void src_set_alignment(struct sof_source *source); struct comp_data { #if CONFIG_IPC_MAJOR_4 diff --git a/src/audio/src/src_ipc3.c b/src/audio/src/src_ipc3.c index b161155193fc..541efcdb24be 100644 --- a/src/audio/src/src_ipc3.c +++ b/src/audio/src/src_ipc3.c @@ -105,7 +105,7 @@ int src_prepare_general(struct processing_module *mod, enum sof_ipc_frame sink_format; /* set align requirements */ - src_set_alignment(source, sink); + src_set_alignment(source); /* get source/sink data format */ source_format = source_get_frm_fmt(source); diff --git a/src/audio/src/src_ipc4.c b/src/audio/src/src_ipc4.c index 1240a86bd48e..91f286347a5f 100644 --- a/src/audio/src/src_ipc4.c +++ b/src/audio/src/src_ipc4.c @@ -151,7 +151,7 @@ int src_prepare_general(struct processing_module *mod, int ret = 0; /* set align requirements */ - src_set_alignment(source, sink); + src_set_alignment(source); switch (cd->ipc_config.base.audio_fmt.valid_bit_depth) { #if CONFIG_FORMAT_S16LE diff --git a/src/audio/tdfb/tdfb.c b/src/audio/tdfb/tdfb.c index fa6a207d49e6..5df4563c3558 100644 --- a/src/audio/tdfb/tdfb.c +++ b/src/audio/tdfb/tdfb.c @@ -689,14 +689,12 @@ static int tdfb_process(struct processing_module *mod, return 0; } -static void tdfb_set_alignment(struct audio_stream *source, - struct audio_stream *sink) +static void tdfb_set_alignment(struct audio_stream *source) { - const uint32_t byte_align = 1; + const uint32_t byte_align = SOF_FRAME_BYTE_ALIGN; const uint32_t frame_align_req = 2; /* Process multiples of 2 frames */ audio_stream_set_align(byte_align, frame_align_req, source); - audio_stream_set_align(byte_align, frame_align_req, sink); } static int tdfb_prepare(struct processing_module *mod, @@ -729,7 +727,7 @@ static int tdfb_prepare(struct processing_module *mod, return ret; } - tdfb_set_alignment(&sourceb->stream, &sinkb->stream); + tdfb_set_alignment(&sourceb->stream); frame_fmt = audio_stream_get_frm_fmt(&sourceb->stream); source_channels = audio_stream_get_channels(&sourceb->stream);