-
Notifications
You must be signed in to change notification settings - Fork 350
Audio: Volume: Fix the ramping and ZC mode align #10704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
07815d2
531c255
ab79b4e
20c06c4
2427f43
40eac58
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -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, | |||||||
| } | ||||||||
|
|
||||||||
|
||||||||
| mixer_set_frame_alignment(&sink->stream); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand how the sink write could become misaligned since it follows the source align with same amount of frames and samples.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a comment why the sink align constraints are not set.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -591,9 +591,55 @@ audio_stream_avail_frames(const struct audio_stream *source, | |
| } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit/typo: "caused by logic int the function" -> "in the function" |
||
|
|
||
| /** | ||
| * 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. | ||
| * 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; | ||
|
singalsu marked this conversation as resolved.
|
||
|
|
||
| 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); | ||
| } | ||
|
|
||
| /** | ||
| * 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. | ||
|
|
@@ -602,14 +648,11 @@ 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; | ||
| 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 MIN(src_frames, sink_frames); | ||
| return audio_stream_align_frames_round_down(source, n); | ||
| } | ||
|
|
||
| /** | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eq_fir_set_alignment()still takes asinkparameter but no longer uses it, which can trigger-Wunused-parameter(often treated as an error). Either remove the unused parameter (and adjust callers) or explicitly mark it unused.