diff --git a/src/audio/google/google_rtc_audio_processing_mock.c b/src/audio/google/google_rtc_audio_processing_mock.c index 6073e125a539..fe219d36e695 100644 --- a/src/audio/google/google_rtc_audio_processing_mock.c +++ b/src/audio/google/google_rtc_audio_processing_mock.c @@ -10,6 +10,8 @@ #include #include +#include +#include #include #include "ipc/topology.h" @@ -145,11 +147,17 @@ int GoogleRtcAudioProcessingProcessCapture_int16(GoogleRtcAudioProcessingState * int16_t *ref = state->aec_reference; int16_t *mic = (int16_t *) src; int16_t *out = dest; - int n; + int channels; + int n, m; + + channels = MIN(state->num_capture_channels, state->num_aec_reference_channels); + channels = MIN(state->num_output_channels, channels); memset(dest, 0, sizeof(int16_t) * state->num_output_channels * state->num_frames); for (n = 0; n < state->num_frames; ++n) { - *out = *mic + *ref; + for (m = 0; m < channels; m++) + out[m] = sat_int16((int32_t)mic[m] + ref[m]); + ref += state->num_aec_reference_channels; out += state->num_output_channels; mic += state->num_capture_channels;