Skip to content

Commit 6118d85

Browse files
lrgirdwolgirdwood
authored andcommitted
rtc: mock: clean up memory failure handling in Setup()
Currently the caller checks for allocation failure in the callee. Make the correct function check for allocation failure. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent 4080f4b commit 6118d85

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/audio/google/google_rtc_audio_processing_mock.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct GoogleRtcAudioProcessingState {
2727
float *aec_reference;
2828
};
2929

30-
static void SetFormats(GoogleRtcAudioProcessingState *const state,
30+
static int SetFormats(GoogleRtcAudioProcessingState *const state,
3131
int capture_sample_rate_hz,
3232
int num_capture_input_channels,
3333
int num_capture_output_channels,
@@ -45,6 +45,9 @@ static void SetFormats(GoogleRtcAudioProcessingState *const state,
4545
sizeof(state->aec_reference[0]) *
4646
state->num_frames *
4747
state->num_aec_reference_channels);
48+
if (!state->aec_reference)
49+
return -ENOMEM;
50+
return 0;
4851
}
4952

5053
void GoogleRtcAudioProcessingAttachMemoryBuffer(uint8_t *const buffer,
@@ -64,20 +67,21 @@ GoogleRtcAudioProcessingState *GoogleRtcAudioProcessingCreateWithConfig(int capt
6467
const uint8_t *const config,
6568
int config_size)
6669
{
70+
int err;
6771
struct GoogleRtcAudioProcessingState *s =
6872
rballoc(SOF_MEM_FLAG_USER, sizeof(GoogleRtcAudioProcessingState));
6973
if (!s)
7074
return NULL;
7175

7276
s->aec_reference = NULL;
73-
SetFormats(s,
77+
err = SetFormats(s,
7478
capture_sample_rate_hz,
7579
num_capture_input_channels,
7680
num_capture_output_channels,
7781
render_sample_rate_hz,
7882
num_render_channels);
7983

80-
if (!s->aec_reference) {
84+
if (err) {
8185
rfree(s);
8286
return NULL;
8387
}

0 commit comments

Comments
 (0)