修复语音识别死机的bug

This commit is contained in:
mojingtao 2024-11-12 09:02:01 +08:00
parent 372e744be9
commit 7dd4de87b3
93 changed files with 1874 additions and 1784 deletions

View File

@ -27215,7 +27215,7 @@
"app_config.h" "app_config.h"
"debug.h" "debug.h"
1731286384 source:c:\users\lc\desktop\git\doubao_chat\apps\wifi_daobao\aduio_playback.c 1731312023 source:c:\users\lc\desktop\git\doubao_chat\apps\wifi_daobao\aduio_playback.c
"server/audio_server.h" "server/audio_server.h"
"server/server_core.h" "server/server_core.h"
"system/app_core.h" "system/app_core.h"
@ -27235,12 +27235,13 @@
"asm/sfc_norflash_api.h" "asm/sfc_norflash_api.h"
"event/device_event.h" "event/device_event.h"
1731048266 c:\users\lc\desktop\git\doubao_chat\apps\wifi_daobao\aduio_playback.h 1731310916 c:\users\lc\desktop\git\doubao_chat\apps\wifi_daobao\aduio_playback.h
"fs/fs.h"
1731287995 source:c:\users\lc\desktop\git\doubao_chat\apps\wifi_daobao\aduio_record_queue_new.c 1731313181 source:c:\users\lc\desktop\git\doubao_chat\apps\wifi_daobao\aduio_record_queue_new.c
"aduio_record.h" "aduio_record.h"
1731287961 c:\users\lc\desktop\git\doubao_chat\apps\wifi_daobao\aduio_record.h 1731310963 c:\users\lc\desktop\git\doubao_chat\apps\wifi_daobao\aduio_record.h
"server/audio_server.h" "server/audio_server.h"
"server/server_core.h" "server/server_core.h"
"system/app_core.h" "system/app_core.h"
@ -27257,7 +27258,7 @@
"asm/clock.h" "asm/clock.h"
"aduio_playback.h" "aduio_playback.h"
1731068175 source:c:\users\lc\desktop\git\doubao_chat\apps\wifi_daobao\chat_lwip_http_stream.c 1731324300 source:c:\users\lc\desktop\git\doubao_chat\apps\wifi_daobao\chat_lwip_http_stream.c
"system/includes.h" "system/includes.h"
"wifi/wifi_connect.h" "wifi/wifi_connect.h"
"apps/http_client.h" "apps/http_client.h"
@ -27267,7 +27268,7 @@
1715152831 c:\users\lc\desktop\git\doubao_chat\include_lib\net\cjson_common\cjson.h 1715152831 c:\users\lc\desktop\git\doubao_chat\include_lib\net\cjson_common\cjson.h
<stddef.h> <stddef.h>
1731289210 source:c:\users\lc\desktop\git\doubao_chat\apps\wifi_daobao\stt_websocket_queue.c 1731325239 source:c:\users\lc\desktop\git\doubao_chat\apps\wifi_daobao\stt_websocket_queue.c
"web_socket/websocket_api.h" "web_socket/websocket_api.h"
"wifi/wifi_connect.h" "wifi/wifi_connect.h"
"system/includes.h" "system/includes.h"
@ -27278,7 +27279,7 @@
"mem_leak_test.h" "mem_leak_test.h"
"app_config.h" "app_config.h"
1731061689 source:c:\users\lc\desktop\git\doubao_chat\apps\wifi_daobao\tts_websocket.c 1731312714 source:c:\users\lc\desktop\git\doubao_chat\apps\wifi_daobao\tts_websocket.c
"web_socket/websocket_api.h" "web_socket/websocket_api.h"
"wifi/wifi_connect.h" "wifi/wifi_connect.h"
"system/includes.h" "system/includes.h"

View File

@ -95,6 +95,31 @@ static int playback_buffer_data_out(void)
} }
} }
int playback_file(FILE *res)
{
pbh->file = res;
union audio_req req = {0};
req.dec.volume = 50;
req.dec.output_buf_len = 1024;
req.dec.sample_rate = 0;
req.dec.channel = 0;
req.dec.sample_source = "dac";
req.dec.file = res;
req.dec.cmd = AUDIO_DEC_OPEN;
int err = server_request(pbh->dec_server, AUDIO_REQ_DEC, &req);
if (err) {
return err;
}
req.dec.cmd = AUDIO_DEC_START;
err = server_request(pbh->dec_server, AUDIO_REQ_DEC, &req);
if (err) {;
return err;
}
}
static void audio_buffer_dec_stop(void) static void audio_buffer_dec_stop(void)
{ {
union audio_req req = {0}; union audio_req req = {0};
@ -102,6 +127,11 @@ static void audio_buffer_dec_stop(void)
req.dec.cmd = AUDIO_DEC_STOP; req.dec.cmd = AUDIO_DEC_STOP;
server_request(pbh->dec_server, AUDIO_REQ_DEC, &req); server_request(pbh->dec_server, AUDIO_REQ_DEC, &req);
if(pbh->file){
fclose(pbh->file);
printf("pbh->file is free");
pbh->file = NULL;
}
} }
static void dec_server_event_handler(void *priv, int argc, int *argv) static void dec_server_event_handler(void *priv, int argc, int *argv)
@ -110,11 +140,13 @@ static void dec_server_event_handler(void *priv, int argc, int *argv)
case AUDIO_SERVER_EVENT_ERR: case AUDIO_SERVER_EVENT_ERR:
printf("playback: AUDIO_SERVER_EVENT_ERR\n"); printf("playback: AUDIO_SERVER_EVENT_ERR\n");
case AUDIO_SERVER_EVENT_END: case AUDIO_SERVER_EVENT_END:
w_flag = 0;
printf("playback: AUDIO_SERVER_EVENT_END\n"); printf("playback: AUDIO_SERVER_EVENT_END\n");
audio_buffer_dec_stop(); audio_buffer_dec_stop();
if(w_flag!=0){
w_flag = 0;
os_sem_set(&voice_start_sem,0); os_sem_set(&voice_start_sem,0);
os_sem_post(&voice_start_sem); os_sem_post(&voice_start_sem);
}
break; break;
} }
} }
@ -125,6 +157,8 @@ static int playback_mode_init(void)
memset(pbh, 0, sizeof(struct playback_hdl)); memset(pbh, 0, sizeof(struct playback_hdl));
pbh->file = NULL;
#ifdef CONFIG_STORE_VOLUME #ifdef CONFIG_STORE_VOLUME
if (syscfg_read(CFG_MUSIC_VOL, &pbh->volume, sizeof(pbh->volume)) < 0 || if (syscfg_read(CFG_MUSIC_VOL, &pbh->volume, sizeof(pbh->volume)) < 0 ||
pbh->volume < MIN_VOLUME_VALUE || pbh->volume > MAX_VOLUME_VALUE) { pbh->volume < MIN_VOLUME_VALUE || pbh->volume > MAX_VOLUME_VALUE) {

View File

@ -1,5 +1,6 @@
#ifndef __ADUIO_PLAYBACK_H__ #ifndef __ADUIO_PLAYBACK_H__
#define __ADUIO_PLAYBACK_H__ #define __ADUIO_PLAYBACK_H__
#include "fs/fs.h"
struct tts_response{ struct tts_response{
char *msg; char *msg;
@ -17,6 +18,7 @@ struct playback_hdl {
OS_SEM r_sem; OS_SEM r_sem;
OS_SEM w_sem; OS_SEM w_sem;
volatile u8 run_flag; volatile u8 run_flag;
FILE *file;
}; };
#endif #endif

View File

@ -19,16 +19,6 @@
#define SPEECH_RECOGNITION_BUFFER_SIZE (1024 * 10) #define SPEECH_RECOGNITION_BUFFER_SIZE (1024 * 10)
#define APP_TIMER_CLK clk_get("osc") //获得时钟源
#define MAX_TIME_CNT 0x7fff //最大计数值
#define MIN_TIME_CNT 0x100 //最小计数值
#define AWINLINE __attribute__((always_inline))
#define TSEC SEC_USED(.volatile_ram_code) //当中断1ms一下,建议使用函数放在内部ram
/*#define TSEC*/
typedef struct record_message { typedef struct record_message {
char msg[SPEECH_RECOGNITION_BUFFER_SIZE+1]; char msg[SPEECH_RECOGNITION_BUFFER_SIZE+1];
size_t msg_size; size_t msg_size;

View File

@ -176,7 +176,7 @@ static int encoder_init(int sample_rate, u8 channel)
} else { } else {
req.enc.channel_bit_map = BIT(CONFIG_AUDIO_ADC_CHANNEL_L); req.enc.channel_bit_map = BIT(CONFIG_AUDIO_ADC_CHANNEL_L);
} }
req.enc.frame_size = sample_rate / 100 * 8 * channel; //收集够多少字节MP3数据就回调一次fwrite req.enc.frame_size = sample_rate / 100 * 1 * channel; //收集够多少字节MP3数据就回调一次fwrite
req.enc.output_buf_len = req.enc.frame_size * 3; //底层缓冲buf至少设成3倍frame_size req.enc.output_buf_len = req.enc.frame_size * 3; //底层缓冲buf至少设成3倍frame_size
req.enc.cmd = AUDIO_ENC_OPEN; req.enc.cmd = AUDIO_ENC_OPEN;
req.enc.channel = channel; req.enc.channel = channel;
@ -194,7 +194,7 @@ static int encoder_init(int sample_rate, u8 channel)
if(req.enc.use_vad == 1){ if(req.enc.use_vad == 1){
req.enc.vad_start_threshold = 0; //ms req.enc.vad_start_threshold = 0; //ms
req.enc.vad_stop_threshold = 2000; //ms req.enc.vad_stop_threshold = 1000; //ms
} }
err = server_request(rech->enc_server, AUDIO_REQ_ENC, &req); err = server_request(rech->enc_server, AUDIO_REQ_ENC, &req);
if (err) { if (err) {
@ -252,15 +252,15 @@ static void record_encoder_start_task(void)
memset(&req,0,sizeof(union audio_req)); memset(&req,0,sizeof(union audio_req));
req.dec.cmd = AUDIO_DEC_GET_STATUS; req.dec.cmd = AUDIO_DEC_GET_STATUS;
server_request(playback_handler.dec_server, AUDIO_REQ_DEC, &req); server_request(playback_handler.dec_server, AUDIO_REQ_DEC, &req);
printf("req.dec.status1:%d\r\n",req.dec.status); //printf("req.dec.status1:%d\r\n",req.dec.status);
if(req.dec.status==AUDIO_DEC_STOP){ if(req.dec.status==AUDIO_DEC_STOP){
printf("req.dec.status2:%d\r\n",req.dec.status); //printf("req.dec.status2:%d\r\n",req.dec.status);
memset(&req,0,sizeof(union audio_req)); memset(&req,0,sizeof(union audio_req));
req.enc.cmd = AUDIO_ENC_START; req.enc.cmd = AUDIO_ENC_START;
server_request(rech->enc_server, AUDIO_REQ_ENC, &req); server_request(rech->enc_server, AUDIO_REQ_ENC, &req);
}else{ }else{
printf("req.dec.status3:%d\r\n",req.dec.status); //printf("req.dec.status3:%d\r\n",req.dec.status);
w_flag = 0; w_flag = 0;
cbuf_clear(&playback_handler.save_cbuf); cbuf_clear(&playback_handler.save_cbuf);
memset(&req,0,sizeof(union audio_req)); memset(&req,0,sizeof(union audio_req));

View File

@ -28,6 +28,8 @@ static size_t buffer_len = 0;
char accumulated_content[10*1024] = {0}; char accumulated_content[10*1024] = {0};
static size_t accumulated_length = 0; static size_t accumulated_length = 0;
static size_t add_length = 0; static size_t add_length = 0;
static size_t sup_length = 0;
static size_t sent_length = 0;
static msg_session msg_arr[MAX_MSG_LENGTH]; static msg_session msg_arr[MAX_MSG_LENGTH];
@ -37,6 +39,8 @@ extern unsigned char chat_msg[4 * 1024];
extern OS_SEM chat_sem; extern OS_SEM chat_sem;
extern OS_SEM disconnet_sem;
extern OS_MUTEX http_mutex; extern OS_MUTEX http_mutex;
extern u8 sock_run_flag; extern u8 sock_run_flag;
@ -46,6 +50,7 @@ OS_SEM tts_sem;
static void process_sse_chunk(const char *chunk) static void process_sse_chunk(const char *chunk)
{ {
int argv[4]; int argv[4];
int diff_len,j;
const char *data_start = strstr(chunk, "data:"); const char *data_start = strstr(chunk, "data:");
if (!data_start) { if (!data_start) {
return; return;
@ -56,6 +61,20 @@ static void process_sse_chunk(const char *chunk)
if (strcmp(data_start, "[DONE]") == 0) { if (strcmp(data_start, "[DONE]") == 0) {
printf("SSE stream ended\r\n"); printf("SSE stream ended\r\n");
printf("answer: %s\r\n",accumulated_content); printf("answer: %s\r\n",accumulated_content);
// diff_len = accumulated_length-sent_length;
// if(diff_len>0){
// for(j=0;j<(diff_len/5)+1;j++){
// argv[0]=accumulated_length;
// argv[1]=diff_len;
// if(diff_len>5){
// diff_len-=5;
// }
// os_sem_set(&tts_sem,0);
// os_sem_post(&tts_sem);
// os_taskq_post_type("websockets_tts_client_main_thread", Q_USER, 20, argv);
// }
// }
if(chat_index>=MAX_MSG_LENGTH){ if(chat_index>=MAX_MSG_LENGTH){
chat_index = MAX_MSG_LENGTH-1; chat_index = MAX_MSG_LENGTH-1;
for (int i = 1; i < MAX_MSG_LENGTH; i++) { for (int i = 1; i < MAX_MSG_LENGTH; i++) {
@ -92,11 +111,17 @@ static void process_sse_chunk(const char *chunk)
strcmp(content->valuestring,";")==0){ strcmp(content->valuestring,";")==0){
//printf("sentence:%s\r\n",accumulated_content+(accumulated_length-add_length)); //printf("sentence:%s\r\n",accumulated_content+(accumulated_length-add_length));
argv[0]=accumulated_length; argv[0]=accumulated_length;
// sup_length=0;
// if(add_length>5){
// sup_length = add_length-5;
// add_length = 5;
// }
// sent_length+=add_length;
argv[1]=add_length; argv[1]=add_length;
os_sem_set(&tts_sem,0); os_sem_set(&tts_sem,0);
os_sem_post(&tts_sem); os_sem_post(&tts_sem);
os_taskq_post_type("websockets_tts_client_main_thread", Q_USER, 20, argv); os_taskq_post_type("websockets_tts_client_main_thread", Q_USER, 20, argv);
add_length = 0; add_length = 0+sup_length;
} }
} }
} }
@ -225,9 +250,9 @@ static void http_chat_task(void *priv)
accumulated_length = 0; accumulated_length = 0;
printf("httpc_get_file_dns_start\r\n"); printf("httpc_get_file_dns_start\r\n");
os_mutex_pend(&http_mutex, 0);
httpc_get_file_dns(server_name, port, uri, &setting,http_rev_func, NULL, NULL); httpc_get_file_dns(server_name, port, uri, &setting,http_rev_func, NULL, NULL);
os_mutex_post(&http_mutex); os_sem_set(&disconnet_sem,0);
os_sem_post(&disconnet_sem);
printf("httpc_get_file_dns_end\r\n"); printf("httpc_get_file_dns_end\r\n");
free(http_data); free(http_data);

View File

@ -84,7 +84,7 @@ OS_SEM chat_sem;
OS_MUTEX http_mutex; OS_MUTEX http_mutex;
static OS_SEM disconnet_sem; OS_SEM disconnet_sem;
static OS_SEM websocket_send_sem; static OS_SEM websocket_send_sem;
@ -94,7 +94,7 @@ static void websockets_callback(u8 *buf, u32 len, u8 type)
{ {
int argv[4]; int argv[4];
int err; int err;
u8 *temp; // u8 *temp;
if(buf!=NULL&&type!=0x89){ if(buf!=NULL&&type!=0x89){
// temp = calloc(1,len+1); // temp = calloc(1,len+1);
// memcpy(temp,buf,len); // memcpy(temp,buf,len);
@ -105,7 +105,8 @@ static void websockets_callback(u8 *buf, u32 len, u8 type)
if (err == OS_Q_FULL) { if (err == OS_Q_FULL) {
printf("post request err!\r\n"); printf("post request err!\r\n");
} }
os_sem_post(&websocket_send_sem); // os_sem_set(&websocket_send_sem,0);
// os_sem_post(&websocket_send_sem);
} }
} }
@ -396,6 +397,7 @@ static void websockets_stt_client_main_thread(void *priv)
char *aduio_client_request=NULL; char *aduio_client_request=NULL;
rec_msg *rmsg=NULL; rec_msg *rmsg=NULL;
int frist_voice=0; int frist_voice=0;
char name[128];
AsrWsClient STTPayload={ AsrWsClient STTPayload={
.appid="8571950639", .appid="8571950639",
@ -420,7 +422,8 @@ static void websockets_stt_client_main_thread(void *priv)
/* 0 . malloc buffer */ /* 0 . malloc buffer */
struct websocket_struct *websockets_info = malloc(sizeof(struct websocket_struct)); struct websocket_struct *websockets_info = malloc(sizeof(struct websocket_struct));
if (!websockets_info) { if (!websockets_info) {
break; printf(" . ! websockets_info malloc error !!!\r\n");
continue;
} }
/* 1 . register */ /* 1 . register */
websockets_client_reg(websockets_info, mode); websockets_client_reg(websockets_info, mode);
@ -429,18 +432,18 @@ static void websockets_stt_client_main_thread(void *priv)
err = websockets_client_init(websockets_info, url, origin_str, user_agent_str); err = websockets_client_init(websockets_info, url, origin_str, user_agent_str);
if (FALSE == err) { if (FALSE == err) {
printf(" . ! Cilent websocket init error !!!\r\n"); printf(" . ! Cilent websocket init error !!!\r\n");
break; continue;
} }
/* 3 . hanshack */ /* 3 . hanshack */
printf("websockets_client_handshack_start\r\n"); // printf("websockets_client_handshack_start\r\n");
os_mutex_pend(&http_mutex, 0); // os_mutex_pend(&http_mutex, 0);
err = websockets_client_handshack(websockets_info); err = websockets_client_handshack(websockets_info);
os_mutex_post(&http_mutex); // os_mutex_post(&http_mutex);
printf("websockets_client_handshack_end\r\n"); // printf("websockets_client_handshack_end\r\n");
if (FALSE == err) { if (FALSE == err) {
printf(" . ! Handshake error !!!\r\n"); printf(" . ! Handshake error !!!\r\n");
break; continue;
} }
printf(" . Handshake success \r\n"); printf(" . Handshake success \r\n");
/* 4 . CreateThread */ /* 4 . CreateThread */
@ -464,11 +467,22 @@ static void websockets_stt_client_main_thread(void *priv)
break; break;
} }
rmsg=(rec_msg *)msg[1]; rmsg=(rec_msg *)msg[1];
if(frist_voice==0){ if(frist_voice==0){
FILE *f = fopen("mnt/sdfile/res/ai_res/boot.amr", "r");
if (!f) {
printf("fopen err!\n");
}else{
fget_name(f, name, sizeof(name));
printf("file_name: %s\n", name);
extern int playback_file(FILE *res);
playback_file(f);
}
websocket_header=generate_header(DEFAULT_HEADR); websocket_header=generate_header(DEFAULT_HEADR);
if(websocket_header==NULL){ if(websocket_header==NULL){
@ -516,7 +530,7 @@ static void websockets_stt_client_main_thread(void *priv)
} }
os_sem_pend(&websocket_send_sem,0); // os_sem_pend(&websocket_send_sem,0);
err = websockets_client_send(websockets_info, (u8 *)full_client_request, total_length, WCT_TXTDATA); err = websockets_client_send(websockets_info, (u8 *)full_client_request, total_length, WCT_TXTDATA);
if (FALSE == err) { if (FALSE == err) {
printf(" . ! send err !!!\r\n"); printf(" . ! send err !!!\r\n");
@ -590,20 +604,19 @@ static void websockets_stt_client_main_thread(void *priv)
thread_kill(&websockets_info->ping_thread_id, KILL_REQ); thread_kill(&websockets_info->ping_thread_id, KILL_REQ);
} }
if (websockets_info->recv_thread_id) { if (websockets_info->recv_thread_id) {
thread_kill(&websockets_info->recv_thread_id, KILL_REQ); thread_kill(&websockets_info->recv_thread_id, KILL_WAIT);
} }
websockets_client_exit(websockets_info); websockets_client_exit(websockets_info);
if(websockets_info!=NULL){ if(websockets_info!=NULL){
free(websockets_info); free(websockets_info);
websockets_info = NULL;
} }
if(rmsg!=NULL){ if(rmsg!=NULL){
free(rmsg); free(rmsg);
rmsg = NULL; rmsg = NULL;
} }
if(websocket_header!=NULL) if(websocket_header!=NULL)
free(websocket_header); free(websocket_header);
@ -616,7 +629,6 @@ static void websockets_stt_client_main_thread(void *priv)
if(aduio_client_request!=NULL) if(aduio_client_request!=NULL)
free(aduio_client_request); free(aduio_client_request);
} }
} }
@ -646,6 +658,12 @@ static void websockets_stt_client_request_handle(void *priv){
cJSON* json = cJSON_Parse(req->payload_msg); cJSON* json = cJSON_Parse(req->payload_msg);
if(json!=NULL){ if(json!=NULL){
cJSON *code = cJSON_GetObjectItem(json, "code");
if(cJSON_IsNumber(code)){
if(code->valueint!=1000){
os_sem_set(&voice_start_sem,0);
os_sem_post(&voice_start_sem);
}else{
cJSON *sequence = cJSON_GetObjectItem(json, "sequence"); cJSON *sequence = cJSON_GetObjectItem(json, "sequence");
if(cJSON_IsNumber(sequence)){ if(cJSON_IsNumber(sequence)){
if(sequence->valueint<0){ if(sequence->valueint<0){
@ -658,8 +676,8 @@ static void websockets_stt_client_request_handle(void *priv){
if (cJSON_IsString(text) && (text->valuestring != NULL)) { if (cJSON_IsString(text) && (text->valuestring != NULL)) {
//printf("text: %s\r\n", (unsigned char*)text->valuestring); //printf("text: %s\r\n", (unsigned char*)text->valuestring);
sprintf(chat_msg,"%s",text->valuestring); sprintf(chat_msg,"%s",text->valuestring);
os_sem_set(&disconnet_sem,0); // os_sem_set(&disconnet_sem,0);
os_sem_post(&disconnet_sem); // os_sem_post(&disconnet_sem);
os_sem_set(&chat_sem,0); os_sem_set(&chat_sem,0);
os_sem_post(&chat_sem); os_sem_post(&chat_sem);
@ -668,6 +686,9 @@ static void websockets_stt_client_request_handle(void *priv){
} }
} }
} }
}
}
cJSON_Delete(json); cJSON_Delete(json);
} }
if(req!=NULL) if(req!=NULL)
@ -680,7 +701,7 @@ void stt_websocket_client_thread_create(void)
os_sem_create(&disconnet_sem,0); os_sem_create(&disconnet_sem,0);
os_sem_create(&chat_sem,0); os_sem_create(&chat_sem,0);
os_mutex_create(&http_mutex); os_mutex_create(&http_mutex);
os_sem_create(&websocket_send_sem,1); //os_sem_create(&websocket_send_sem,1);
thread_fork("websockets_stt_client_main_thread", 16, 1024 * 8, 512, 0, websockets_stt_client_main_thread, NULL); thread_fork("websockets_stt_client_main_thread", 16, 1024 * 8, 512, 0, websockets_stt_client_main_thread, NULL);
} }

View File

@ -82,7 +82,7 @@ static void websockets_callback(u8 *buf, u32 len, u8 type)
extern char* tts_parse_response(uint8_t *res,int *len); extern char* tts_parse_response(uint8_t *res,int *len);
tts_req = calloc(1,sizeof(struct tts_response)); tts_req = malloc(sizeof(struct tts_response));
if(!tts_req){ if(!tts_req){
perror("Failed to allocate memory"); perror("Failed to allocate memory");
} }
@ -294,7 +294,7 @@ static char* tts_parse_response(uint8_t *res,int *len) {
*len = payload_size; *len = payload_size;
// 为输出字符串分配内存 // 为输出字符串分配内存
char *output = (char *)calloc(1,payload_size+1); char *output = (char *)malloc(payload_size+1);
if (output == NULL) { if (output == NULL) {
perror("Failed to allocate memory"); perror("Failed to allocate memory");
return NULL; // 内存分配错误 return NULL; // 内存分配错误
@ -420,9 +420,9 @@ static void websockets_tts_client_main_thread(void *priv)
} }
/* 3 . hanshack */ /* 3 . hanshack */
os_mutex_pend(&http_mutex, 0); // os_mutex_pend(&http_mutex, 0);
err = websockets_client_handshack(websockets_info); err = websockets_client_handshack(websockets_info);
os_mutex_post(&http_mutex); // os_mutex_post(&http_mutex);
if (FALSE == err) { if (FALSE == err) {
printf(" . ! Handshake error !!!\r\n"); printf(" . ! Handshake error !!!\r\n");
goto exit_ws; goto exit_ws;
@ -468,6 +468,7 @@ static void websockets_tts_client_main_thread(void *priv)
payload_text = calloc(1,add_len+1); payload_text = calloc(1,add_len+1);
if(!payload_text){ if(!payload_text){
perror("Failed to allocate memory");
goto exit_ws; goto exit_ws;
} }
@ -476,13 +477,15 @@ static void websockets_tts_client_main_thread(void *priv)
TTSPayload.text = payload_text; TTSPayload.text = payload_text;
payload=construct_request(&TTSPayload, uuid); payload=construct_request(&TTSPayload, uuid);
free(payload_text);
if(!payload){ if(!payload){
goto exit_ws; goto exit_ws;
} }
if(payload_text!=NULL){
free(payload_text);
payload_text = NULL;
}
//printf(" . Payload :%s \r\n",payload); //printf(" . Payload :%s \r\n",payload);
payload_length=strlen(payload); payload_length=strlen(payload);
@ -502,9 +505,15 @@ static void websockets_tts_client_main_thread(void *priv)
memcpy(full_client_request + 4 + header_length,payload,payload_length+1); memcpy(full_client_request + 4 + header_length,payload,payload_length+1);
if(websocket_header!=NULL){
free(websocket_header); free(websocket_header);
websocket_header = NULL;
}
if(payload!=NULL){
free(payload); free(payload);
payload = NULL;
}
err = websockets_client_send(websockets_info, (u8 *)full_client_request, total_length, WCT_TXTDATA); err = websockets_client_send(websockets_info, (u8 *)full_client_request, total_length, WCT_TXTDATA);
if (FALSE == err) { if (FALSE == err) {
@ -512,7 +521,10 @@ static void websockets_tts_client_main_thread(void *priv)
goto exit_ws; goto exit_ws;
} }
if(full_client_request!=NULL){
free(full_client_request); free(full_client_request);
full_client_request = NULL;
}
} }
exit_ws: exit_ws:
@ -540,5 +552,4 @@ void tts_websocket_client_thread_create(void)
{ {
thread_fork("websockets_tts_client_main_thread", 15, 1024 * 6, 1024, 0, websockets_tts_client_main_thread, NULL); thread_fork("websockets_tts_client_main_thread", 15, 1024 * 6, 1024, 0, websockets_tts_client_main_thread, NULL);
} }
#endif // tts #endif // tts

View File

@ -172,7 +172,7 @@ set OBJDUMP=C:\JL\pi32\bin\llvm-objdump.exe
set OBJCOPY=C:\JL\pi32\bin\llvm-objcopy.exe set OBJCOPY=C:\JL\pi32\bin\llvm-objcopy.exe
set ELFFILE=sdk.elf set ELFFILE=sdk.elf
REM %OBJDUMP% -D -address-mask=0x1ffffff -print-dbg %ELFFILE% > sdk.lst %OBJDUMP% -D -address-mask=0x1ffffff -print-dbg %ELFFILE% > sdk.lst
%OBJCOPY% -O binary -j .text %ELFFILE% text.bin %OBJCOPY% -O binary -j .text %ELFFILE% text.bin
%OBJCOPY% -O binary -j .data %ELFFILE% data.bin %OBJCOPY% -O binary -j .data %ELFFILE% data.bin
%OBJCOPY% -O binary -j .ram0_data %ELFFILE% ram0_data.bin %OBJCOPY% -O binary -j .ram0_data %ELFFILE% ram0_data.bin
@ -230,7 +230,7 @@ fat_image_tool.exe --size CONFIG_SDNAND_HFAT_LEN_TEXT --sectors-per-cluster CONF
fat_image_tool.exe --size CONFIG_SDNAND_FAT1_LEN_TEXT --sectors-per-cluster CONFIG_SDNAND_FAT1_CLUSTER_SIZE --lfn true --n-root 512 --volume-name FAT1_IMG --output jl_fat1.bin --fat-dir fat1_dir fat_image_tool.exe --size CONFIG_SDNAND_FAT1_LEN_TEXT --sectors-per-cluster CONFIG_SDNAND_FAT1_CLUSTER_SIZE --lfn true --n-root 512 --volume-name FAT1_IMG --output jl_fat1.bin --fat-dir fat1_dir
isd_download.exe isd_config.ini -gen2 -to-sdcard -dev wl82 -boot 0x1c02000 -div1 -app app.bin cfg_tool.bin -res %AUDIO_RES% %UI_RES% cfg -extend-bin -output-bin jl_hfs.bin %UPDATE_FILES% -no-app-bin-enc isd_download.exe isd_config.ini -gen2 -to-sdcard -dev wl82 -boot 0x1c02000 -div1 -app app.bin cfg_tool.bin -res %AUDIO_RES% %UI_RES% cfg -extend-bin -output-bin jl_hfs.bin %UPDATE_FILES% -no-app-bin-enc
#elif defined CONFIG_SFC_ENABLE #elif defined CONFIG_SFC_ENABLE
isd_download.exe isd_config.ini -tonorflash -dev wl82 -boot 0x1c02000 -div1 -wait 300 -uboot uboot.boot -app app.bin cfg_tool.bin -res %AUDIO_RES% %UI_RES% %CFG_FILE% -reboot 500 %KEY_FILE% %UPDATE_FILES% -extend-bin isd_download.exe isd_config.ini -tonorflash -dev wl82 -boot 0x1c02000 -div1 -wait 300 -uboot uboot.boot -app app.bin cfg_tool.bin -res ai_res %AUDIO_RES% %UI_RES% %CFG_FILE% -reboot 500 %KEY_FILE% %UPDATE_FILES% -extend-bin
#else #else
REM @@@@@@@无效参数 REM @@@@@@@无效参数
set run_addr=0x2000 set run_addr=0x2000
@ -239,7 +239,7 @@ set mask_addr=0x100000
uboot_lz4.exe app.bin app.lz4 %run_addr% %load_addr% rom.image %mask_addr% uboot_lz4.exe app.bin app.lz4 %run_addr% %load_addr% rom.image %mask_addr%
REM @@@@@@@@@@@@@@@ REM @@@@@@@@@@@@@@@
isd_download.exe isd_config.ini -tonorflash -dev wl82 -boot 0x1c02000 -div1 -wait 300 -uboot uboot.boot -app app.lz4 cfg_tool.bin -res %AUDIO_RES% %UI_RES% %CFG_FILE% -reboot 500 %KEY_FILE% %UPDATE_FILES% -extend-bin isd_download.exe isd_config.ini -tonorflash -dev wl82 -boot 0x1c02000 -div1 -wait 300 -uboot uboot.boot -app app.lz4 cfg_tool.bin -res ai_res %AUDIO_RES% %UI_RES% %CFG_FILE% -reboot 500 %KEY_FILE% %UPDATE_FILES% -extend-bin
#endif #endif

File diff suppressed because it is too large Load Diff