From 1cd8de6048c3ae2dc85229b8f4b6df79ecc48cb3 Mon Sep 17 00:00:00 2001 From: Andy Ross Date: Mon, 8 Jan 2024 07:32:06 -0800 Subject: [PATCH] audio_stream: Rename/redocument audio_stream_set_align After recent changes, the audio_stream_init_alignment_constants() routine isn't an "init" step anymore, it sets requirements and can be called at any time. Rename it to "audio_stream_set_align()" to better capture its behavior, and rework the documentation to make it clearer how it works. Signed-off-by: Andy Ross --- src/audio/aria/aria.c | 2 +- src/audio/audio_stream.c | 8 ++++---- src/audio/eq_fir/eq_fir.c | 4 ++-- src/audio/eq_iir/eq_iir.c | 4 ++-- src/audio/mixer/mixer.c | 2 +- src/audio/selector/selector.c | 4 ++-- src/audio/tdfb/tdfb.c | 4 ++-- src/audio/volume/volume.c | 4 ++-- src/include/sof/audio/audio_stream.h | 22 +++++++++++----------- 9 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/audio/aria/aria.c b/src/audio/aria/aria.c index cd9046e61dea..16d6eea1565d 100644 --- a/src/audio/aria/aria.c +++ b/src/audio/aria/aria.c @@ -163,7 +163,7 @@ static void aria_set_stream_params(struct comp_buffer *buffer, ipc4_update_buffer_format(buffer, audio_fmt); #ifndef ARIA_GENERIC - audio_stream_init_alignment_constants(8, 1, &buffer->stream); + audio_stream_set_align(8, 1, &buffer->stream); #endif } diff --git a/src/audio/audio_stream.c b/src/audio/audio_stream.c index 8e6528c8cd8d..d479bf80c788 100644 --- a/src/audio/audio_stream.c +++ b/src/audio/audio_stream.c @@ -93,7 +93,7 @@ void audio_stream_recalc_align(struct audio_stream *stream) (is_power_of_2(process_size) ? 31 : 32) - clz(process_size); } -void audio_stream_init_alignment_constants(const uint32_t byte_align, +void audio_stream_set_align(const uint32_t byte_align, const uint32_t frame_align_req, struct audio_stream *stream) { @@ -139,7 +139,7 @@ static int audio_stream_source_set_alignment_constants(struct sof_source *source { struct audio_stream *audio_stream = container_of(source, struct audio_stream, source_api); - audio_stream_init_alignment_constants(byte_align, frame_align_req, audio_stream); + audio_stream_set_align(byte_align, frame_align_req, audio_stream); return 0; } @@ -150,7 +150,7 @@ static int audio_stream_sink_set_alignment_constants(struct sof_sink *sink, { struct audio_stream *audio_stream = container_of(sink, struct audio_stream, sink_api); - audio_stream_init_alignment_constants(byte_align, frame_align_req, audio_stream); + audio_stream_set_align(byte_align, frame_align_req, audio_stream); return 0; } @@ -195,7 +195,7 @@ 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_init_alignment_constants(1, 1, audio_stream); + audio_stream_set_align(1, 1, audio_stream); source_init(audio_stream_get_source(audio_stream), &audio_stream_source_ops, &audio_stream->runtime_stream_params); sink_init(audio_stream_get_sink(audio_stream), &audio_stream_sink_ops, diff --git a/src/audio/eq_fir/eq_fir.c b/src/audio/eq_fir/eq_fir.c index 3068cd0971c2..b7402dba2207 100644 --- a/src/audio/eq_fir/eq_fir.c +++ b/src/audio/eq_fir/eq_fir.c @@ -402,8 +402,8 @@ static void eq_fir_set_alignment(struct audio_stream *source, const uint32_t byte_align = 1; const uint32_t frame_align_req = 2; /* Process multiples of 2 frames */ - audio_stream_init_alignment_constants(byte_align, frame_align_req, source); - audio_stream_init_alignment_constants(byte_align, frame_align_req, sink); + 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, diff --git a/src/audio/eq_iir/eq_iir.c b/src/audio/eq_iir/eq_iir.c index b5d539759091..3c3312d1557c 100644 --- a/src/audio/eq_iir/eq_iir.c +++ b/src/audio/eq_iir/eq_iir.c @@ -174,8 +174,8 @@ static void eq_iir_set_alignment(struct audio_stream *source, const uint32_t byte_align = 8; const uint32_t frame_align_req = 2; - audio_stream_init_alignment_constants(byte_align, frame_align_req, source); - audio_stream_init_alignment_constants(byte_align, frame_align_req, sink); + audio_stream_set_align(byte_align, frame_align_req, source); + audio_stream_set_align(byte_align, frame_align_req, sink); } static int eq_iir_prepare(struct processing_module *mod, diff --git a/src/audio/mixer/mixer.c b/src/audio/mixer/mixer.c index 38be94676c29..e90a75c838ff 100644 --- a/src/audio/mixer/mixer.c +++ b/src/audio/mixer/mixer.c @@ -205,7 +205,7 @@ static inline void mixer_set_frame_alignment(struct audio_stream *source) /*There is no limit for frame number, so set it as 1*/ const uint32_t frame_align_req = 1; - audio_stream_init_alignment_constants(byte_align, frame_align_req, source); + audio_stream_set_align(byte_align, frame_align_req, source); #endif } diff --git a/src/audio/selector/selector.c b/src/audio/selector/selector.c index 136fcac0232a..f2de27b2f3ef 100644 --- a/src/audio/selector/selector.c +++ b/src/audio/selector/selector.c @@ -847,8 +847,8 @@ static int selector_prepare(struct processing_module *mod, sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list); sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list); - audio_stream_init_alignment_constants(4, 1, &sourceb->stream); - audio_stream_init_alignment_constants(4, 1, &sinkb->stream); + audio_stream_set_align(4, 1, &sourceb->stream); + audio_stream_set_align(4, 1, &sinkb->stream); /* get source data format and period bytes */ cd->source_format = audio_stream_get_frm_fmt(&sourceb->stream); diff --git a/src/audio/tdfb/tdfb.c b/src/audio/tdfb/tdfb.c index 7a7f751b1548..149e8dc7982b 100644 --- a/src/audio/tdfb/tdfb.c +++ b/src/audio/tdfb/tdfb.c @@ -518,8 +518,8 @@ static void tdfb_set_alignment(struct audio_stream *source, const uint32_t byte_align = 1; const uint32_t frame_align_req = 2; /* Process multiples of 2 frames */ - audio_stream_init_alignment_constants(byte_align, frame_align_req, source); - audio_stream_init_alignment_constants(byte_align, frame_align_req, sink); + 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, diff --git a/src/audio/volume/volume.c b/src/audio/volume/volume.c index 694d778db6b0..b9f1d1ddbc5b 100644 --- a/src/audio/volume/volume.c +++ b/src/audio/volume/volume.c @@ -632,8 +632,8 @@ static void volume_set_alignment(struct audio_stream *source, /*There is no limit for frame number, so both source and sink set it to be 1*/ const uint32_t frame_align_req = 1; - audio_stream_init_alignment_constants(byte_align, frame_align_req, source); - audio_stream_init_alignment_constants(byte_align, frame_align_req, sink); + audio_stream_set_align(byte_align, frame_align_req, source); + audio_stream_set_align(byte_align, frame_align_req, sink); #endif } diff --git a/src/include/sof/audio/audio_stream.h b/src/include/sof/audio/audio_stream.h index 1a0181c5d659..39211cea13b8 100644 --- a/src/include/sof/audio/audio_stream.h +++ b/src/include/sof/audio/audio_stream.h @@ -338,20 +338,20 @@ static inline uint32_t audio_stream_sample_bytes(const struct audio_stream *buf) } /** - * Set align_shift_idx and align_frame_cnt of stream according to byte_align and - * frame_align_req alignment requirement. Once the channel number,frame size - * are determined,the align_frame_cnt and align_shift_idx are determined too. - * these two feature will be used in audio_stream_get_avail_frames_aligned - * to calculate the available frames. it should be called in component prepare - * or param functions only once before stream copy. if someone forgets to call - * this first, there would be unexampled error such as nothing is copied at all. + * @brief Set processing alignment requirements + * + * Sets the sample byte alignment and aligned frame count required for + * processing done on this stream. This function may be called at any + * time, the internal constants are recalculated if the frame/sample + * size changes. @see audio_stream_avail_frames_aligned(). + * * @param byte_align Processing byte alignment requirement. - * @param frame_align_req Processing frames alignment requirement. + * @param frame_align Processing frames alignment requirement. * @param stream Sink or source stream structure which to be set. */ -void audio_stream_init_alignment_constants(const uint32_t byte_align, - const uint32_t frame_align_req, - struct audio_stream *stream); +void audio_stream_set_align(const uint32_t byte_align, + const uint32_t frame_align_req, + struct audio_stream *stream); /** * Applies parameters to the buffer.