Audio: Component: Fix the potential risks of HiFi3 audio_stream_copy

Use while (shorts > 0) instead of while (short) to reduce the forever
loop risk.

Use general instruction AE_MIN32 replace AE_MIN_32_signed which is an
internal proto intended for Xtensa compiler.

Signed-off-by: Andrula Song <andrula.song@intel.com>
This commit is contained in:
Andrula Song 2024-03-08 15:02:35 +08:00 committed by Kai Vehmanen
parent 50c8aeb710
commit 40c8e477f0
1 changed files with 3 additions and 3 deletions

View File

@ -252,13 +252,13 @@ int audio_stream_copy(const struct audio_stream *source, uint32_t ioffset,
ae_valign outu = AE_ZALIGN64(); ae_valign outu = AE_ZALIGN64();
/* copy with 16bit as the minimum unit since the minimum sample size is 16 bit*/ /* copy with 16bit as the minimum unit since the minimum sample size is 16 bit*/
while (shorts) { while (shorts > 0) {
src = audio_stream_wrap(source, src); src = audio_stream_wrap(source, src);
dst = audio_stream_wrap(sink, dst); dst = audio_stream_wrap(sink, dst);
shorts_src = audio_stream_samples_without_wrap_s16(source, src); shorts_src = audio_stream_samples_without_wrap_s16(source, src);
shorts_dst = audio_stream_samples_without_wrap_s16(sink, dst); shorts_dst = audio_stream_samples_without_wrap_s16(sink, dst);
shorts_copied = AE_MIN_32_signed(shorts_src, shorts_dst); shorts_copied = AE_MIN32(shorts_src, shorts_dst);
shorts_copied = AE_MIN_32_signed(shorts, shorts_copied); shorts_copied = AE_MIN32(shorts, shorts_copied);
m = shorts_copied >> 2; m = shorts_copied >> 2;
left = shorts_copied & 0x03; left = shorts_copied & 0x03;
inu = AE_LA64_PP(src); inu = AE_LA64_PP(src);