不要用esp_websocket_client_send_bin直接发送前导音频,会卡,导致mic声音卡顿,要用环形队列

mic_data_zong0=0;

memcpy(mic_data_zong+1,mac,6);//1-6是设备唯一id

for(int i=0;i<read_len1;i++){

mic_data_zongaddon_sound_buf_len+i=to_VAD_1_pre_audio_dataindex1+i ;

}

size_t total_len = read_len1 + addon_sound_buf_len;

//不要用esp_websocket_client_send_bin直接发送前导音频,会卡,导致mic声音卡顿,要用环形队列:

BaseType_t send_ret =xRingbufferSend(buf_handle, mic_data_zong,

total_len, pdMS_TO_TICKS(2000));

if (send_ret != pdTRUE) {

ESP_LOGE(TAG, "Preamble send001 failed! total_len=%d", total_len);

}

/*

// 直接通过 WebSocket 发送

if (client != nullptr && esp_websocket_client_is_connected(client)) {

if (xSemaphoreTake(ws_mutex, pdMS_TO_TICKS(max_send_wait_time_ms)) == pdTRUE) {

esp_err_t err = esp_websocket_client_send_bin(client,

(const char *)mic_data_zong,

(int)total_len,

portMAX_DELAY);

if (err<0 ) {

ESP_LOGE(TAG, "Preamble send failed: %s", esp_err_to_name(err));//提示是失败,其实发成功了

} else {

ESP_LOGI(TAG, "Preamble sent successfully, len=%d", total_len);

}

xSemaphoreGive(ws_mutex);

} else {

ESP_LOGE(TAG, "Could not take ws_mutex for preamble");

}

} else {

ESP_LOGE(TAG, "WebSocket not connected, preamble dropped");

}

*/

/*

BaseType_t send_ret = xRingbufferSend(buf_handle, mic_data_zong,

pre_len + addon_sound_buf_len, pdMS_TO_TICKS(2000));

ESP_LOGE(TAG, "DEBUG SENDING PREAMBLE!!!,pre_len=%d", pre_len);

if (send_ret != pdTRUE) {

ESP_LOGE(TAG, "Preamble send001 failed! pre_len=%d", pre_len);

}

*/

相关推荐
2301_805962931 天前
ESP32 使用 PlatformIO 编译点灯程序
stm32·esp32
大江东去浪淘尽千古风流人物4 天前
【Micro-WL Robot】桌面级轮腿机器人全栈解析:LQR平衡控制、SimpleFOC驱动与五连杆腿部机构源码深度拆解
驱动开发·机器人·esp32·lqr·simplefoc·轮腿机器人·平衡控制
π同学10 天前
ESP-IDF+vscode开发ESP32第十五讲——队列、流缓冲区、环形缓冲区
vscode·esp32·缓冲区
taiguisheng10 天前
Docker中编译esp32
windows·docker·esp32
止观止14 天前
基于 BSP 组件的 ESP-IDF 开发实践:从零开始点亮 M5Stack CoreS3 屏幕
esp32·esp-idf·m5stack cores3
π同学17 天前
ESP-IDF+vscode开发ESP32第十三讲——NVS
vscode·esp32·nvs
NPE~18 天前
[嵌入式]嵌入式在线仿真平台 —— Wokwi 入门指南
stm32·嵌入式·esp32·教程·平台
小手智联老徐18 天前
Arduino IDE环境搭建与点亮ESP32 D1板载LED
嵌入式硬件·esp32·arduino
π同学19 天前
ESP-IDF+vscode开发ESP32第十二讲——event
vscode·esp32·事件循环库event
桔子雨24 天前
C# ESP32/STM32 轻量 Web 能力库:PicoServer.Nano
esp32·webapi·picoserver·picoserver.nano