From 6b7857ed047dc4605affdf319299dfabe9052cd2 Mon Sep 17 00:00:00 2001 From: Stijn Tintel Date: Tue, 9 Jan 2024 12:47:12 +0200 Subject: [PATCH] audio: add NULL check for SR recorder If the SR recorder cannot be created for some reason, we currently just print "Ready!" on the display. Improve UX by informing the user about the problem. --- main/audio.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/main/audio.c b/main/audio.c index f955c44f..955ed1ed 100644 --- a/main/audio.c +++ b/main/audio.c @@ -851,6 +851,13 @@ static esp_err_t start_rec(void) } free(audio_codec); free(wake_word); + + if (cfg_ar.sr_handle == NULL) { + ESP_LOGE(TAG, "failed to init SR recorder"); + ui_pr_err("Recorder init failed", "Check logs"); + return ESP_FAIL; + } + hdl_ar = audio_recorder_create(&cfg_ar); return ret;