smart_amp_test: process same frames from all inputs

The smart amp test module will first process feedback if
presents, and then process main input to its output.

However, minimum available frames from main input and
feedback is used in processing feedback, while available
frames from main input is used in processing main input.
The different frames of audio data could be processed from
main input buffer and feedback buffer.

This patch make sure the same number of frames are processed
from main input and feedback buffers.

Fixes: #7184

Signed-off-by: Chao Song <chao.song@linux.intel.com>
This commit is contained in:
Chao Song 2023-04-04 10:17:12 +08:00 committed by Kai Vehmanen
parent 6a0db47338
commit 72d4854efa
1 changed files with 6 additions and 4 deletions

View File

@ -652,7 +652,7 @@ static int smart_amp_copy(struct comp_dev *dev)
struct comp_buffer __sparse_cache *sink_buf = buffer_acquire(sad->sink_buf);
uint32_t avail_passthrough_frames;
uint32_t avail_feedback_frames;
uint32_t avail_frames;
uint32_t avail_frames = 0;
uint32_t source_bytes;
uint32_t sink_bytes;
uint32_t feedback_bytes;
@ -694,17 +694,19 @@ static int smart_amp_copy(struct comp_dev *dev)
}
k_mutex_unlock(&sad->lock);
if (!avail_frames)
avail_frames = avail_passthrough_frames;
/* bytes calculation */
source_bytes = avail_passthrough_frames *
source_bytes = avail_frames *
audio_stream_frame_bytes(&source_buf->stream);
sink_bytes = avail_passthrough_frames *
sink_bytes = avail_frames *
audio_stream_frame_bytes(&sink_buf->stream);
/* process data */
buffer_stream_invalidate(source_buf, source_bytes);
sad->process(dev, &source_buf->stream, &sink_buf->stream,
avail_passthrough_frames, sad->config.source_ch_map);
avail_frames, sad->config.source_ch_map);
buffer_stream_writeback(sink_buf, sink_bytes);
/* source/sink buffer pointers update */