Skip to content

Commit

Permalink
audio: mute mic during wake confirmation tone
Browse files Browse the repository at this point in the history
Use ESP Audio's synchronous play, this way we can simply mute before and
unmute after the call.
  • Loading branch information
stintel committed Dec 15, 2023
1 parent 2ac767d commit 6d69f0c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
13 changes: 11 additions & 2 deletions main/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -132,6 +132,15 @@ static void play_audio_wis_tts(void *data)
free(url);
}

void play_wake_confirmation(void *data)
{
es7210_set_mute(true);
gpio_set_level(get_pa_enable_gpio(), 1);
esp_audio_sync_play(hdl_ea, "spiffs://spiffs/user/audio/success.wav", 0);
es7210_set_mute(false);
gpio_set_level(get_pa_enable_gpio(), 0);
}

static void noop(void *data)
{
}
Expand Down Expand Up @@ -370,7 +379,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
Expand Down
2 changes: 1 addition & 1 deletion main/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
2 changes: 1 addition & 1 deletion main/was.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down

0 comments on commit 6d69f0c

Please sign in to comment.