fix(multimodal): protect voice startup from background uploads

This commit is contained in:
chenjintao
2026-08-14 18:23:46 +08:00
parent 451d989e78
commit 609fe978f1
4 changed files with 85 additions and 6 deletions
@@ -88,6 +88,7 @@
#define REMOTE_LOG_UPLOAD_BODY_MAX (CONFIG_TQ_REMOTE_LOG_FILE_MAX_BYTES + 4096)
#define REMOTE_LOG_BACKOFF_MAX_MS 300000
#define REMOTE_LOG_POLL_MS 200
#define REMOTE_LOG_VOICE_STARTUP_GRACE_MS 60000
#if CONFIG_TQ_REMOTE_LOG_ENABLE
@@ -600,20 +601,47 @@ static void drain_memory_queue_to_flash(void)
static bool realtime_path_busy(void)
{
#if CONFIG_TQ_LOCAL_WAKE_ENABLE
if (!control_plane_ota_voice_services_allowed() ||
!control_plane_voice_turn_is_idle()) {
return true;
}
#endif
#if CONFIG_ENABLE_MULTIMODAL_INTERACTION
control_plane_multimodal_runtime_state_t state = {0};
if (control_plane_multimodal_get_runtime_state(&state) != ESP_OK) {
return false;
}
return state.client_speech_active ||
return state.starting ||
(state.connected && state.has_active_task && !state.server_listening) ||
state.client_speech_active ||
state.response_pending ||
state.remote_responding ||
state.request_to_speak_pending ||
state.local_responding_started ||
state.received_downstream_audio;
#else
return false;
#endif
}
static bool voice_startup_upload_gate_open(TickType_t startup_tick)
{
#if CONFIG_TQ_LOCAL_WAKE_ENABLE && CONFIG_ENABLE_MULTIMODAL_INTERACTION
control_plane_multimodal_runtime_state_t state = {0};
if (control_plane_multimodal_get_runtime_state(&state) == ESP_OK &&
state.connected && state.has_active_task && state.server_listening) {
return true;
}
return (xTaskGetTickCount() - startup_tick) >=
pdMS_TO_TICKS(REMOTE_LOG_VOICE_STARTUP_GRACE_MS);
#else
(void)startup_tick;
return true;
#endif
}
static const char *reset_reason_name(esp_reset_reason_t reason)
{
switch (reason) {
@@ -1065,6 +1093,7 @@ static void remote_log_task(void *arg)
log_startup_self_check();
TickType_t last_flush = xTaskGetTickCount();
TickType_t startup_tick = last_flush;
uint32_t backoff_ms = 0U;
TickType_t next_upload_tick = xTaskGetTickCount();
@@ -1075,7 +1104,8 @@ static void remote_log_task(void *arg)
last_flush = now;
}
if (backoff_ms == 0U || now >= next_upload_tick) {
if (voice_startup_upload_gate_open(startup_tick) &&
(backoff_ms == 0U || now >= next_upload_tick)) {
drain_memory_queue_to_flash();
(void)upload_coredump_report();
bool ok = upload_pending_files();