Skip to content

Commit

Permalink
audio_stream: Rename/redocument audio_stream_set_align
Browse files Browse the repository at this point in the history
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 <andyross@google.com>
  • Loading branch information
andyross committed Jan 8, 2024
1 parent f875c8b commit b73a42a
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/audio/aria/aria.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
8 changes: 4 additions & 4 deletions src/audio/audio_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/audio/eq_fir/eq_fir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/audio/eq_iir/eq_iir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/mixer/mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions src/audio/selector/selector.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/audio/tdfb/tdfb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/audio/volume/volume.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
20 changes: 10 additions & 10 deletions src/include/sof/audio/audio_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 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.
Expand Down

0 comments on commit b73a42a

Please sign in to comment.