// ResetAudioStreams();
MEDIA_INFO_LOG("AI voice force interrupt completed");
+
+ if (a2dp_is_connect)
+ {
+ uint32_t queueSize = 0, queueCapacity = 0;
+ AI_GetQueueStatus(&queueSize, &queueCapacity);
+ if (queueSize == 0)
+ {
+ // 使用静音音频数据(自动匹配大小)
+ AIVoiceQueueMessage cachedMsg;
+ cachedMsg.size = SILENCE_AUDIO_SIZE;
+ cachedMsg.data = (uint8_t *)malloc(cachedMsg.size);
+ memcpy(cachedMsg.data, (void*)silence_audio, SILENCE_AUDIO_SIZE);
+
+ osStatus_t queueStatus = osMessageQueuePut(g_aiVoiceContext->inputQueue, &cachedMsg, 0, 0);
+ if (queueStatus == osOK) {
+ g_aiVoiceContext->queueMsgCount++;
+ // MEDIA_INFO_LOG("Successfully restored %u bytes from cache to queue", cachedMsg.size);
+ } else {
+ MEDIA_ERR_LOG("Failed to restore cached data to queue: %d", queueStatus);
+ // 如果队列写入失败,释放内存
+ free(cachedMsg.data);
+ }
+ }
+ }
MediaMutexUnLock(mutex);
return 0;