From dd7b0a0d4688095d25e92c2a735c8e97bb43fbdd Mon Sep 17 00:00:00 2001 From: Stijn Tintel Date: Fri, 15 Dec 2023 15:47:05 +0200 Subject: [PATCH] audio: mute mic during wake confirmation tone Use ESP Audio's synchronous play, this way we can simply mute before and unmute after the call. --- main/audio.c | 11 +++++++++-- main/audio.h | 2 +- main/was.c | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/main/audio.c b/main/audio.c index 2a3fdf2aa..428bed141 100644 --- a/main/audio.c +++ b/main/audio.c @@ -97,7 +97,7 @@ static void play_audio_err(void *data) esp_audio_play(hdl_ea, AUDIO_CODEC_TYPE_DECODER, "spiffs://spiffs/user/audio/error.wav", 0); } -void play_audio_ok(void *data) +static void play_audio_ok(void *data) { gpio_set_level(get_pa_enable_gpio(), 1); esp_audio_play(hdl_ea, AUDIO_CODEC_TYPE_DECODER, "spiffs://spiffs/user/audio/success.wav", 0); @@ -132,6 +132,13 @@ static void play_audio_wis_tts(void *data) free(url); } +void play_wake_confirmation(void *data) +{ + es7210_set_mute(true); + esp_audio_sync_play(hdl_ea, "spiffs://spiffs/user/audio/success.wav", 0); + es7210_set_mute(false); +} + static void noop(void *data) { } @@ -370,7 +377,7 @@ static esp_err_t cb_ar_event(audio_rec_evt_t *are, void *data) } if (!config_get_bool("multiwake", false)) { if (config_get_bool("wake_confirmation", DEFAULT_WAKE_CONFIRMATION)) { - play_audio_ok(NULL); + play_wake_confirmation(NULL); } } // win by default so in case WAS multiwake handling goes wrong we act normally diff --git a/main/audio.h b/main/audio.h index 3761df677..a48d75148 100644 --- a/main/audio.h +++ b/main/audio.h @@ -23,5 +23,5 @@ extern struct willow_audio_response war; void deinit_audio(void); void init_audio(void); -void play_audio_ok(void *data); +void play_wake_confirmation(void *data); esp_err_t volume_set(int volume); diff --git a/main/was.c b/main/was.c index d6ce9ee05..d163f079d 100644 --- a/main/was.c +++ b/main/was.c @@ -81,7 +81,7 @@ static void IRAM_ATTR cb_ws_event(const void *arg_evh, const esp_event_base_t *b audio_recorder_trigger_stop(hdl_ar); goto cleanup; } else if (config_get_bool("wake_confirmation", DEFAULT_WAKE_CONFIRMATION)) { - play_audio_ok(NULL); + play_wake_confirmation(NULL); } } }