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 331e20a commit dd7b0a0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
11 changes: 9 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,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)
{
}
Expand Down Expand Up @@ -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
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 dd7b0a0

Please sign in to comment.