回退voice_call的一些修改提交
authorluozheng <1732036298@qq.com>
Thu, 7 Aug 2025 04:15:10 +0000 (12:15 +0800)
committerluozheng <1732036298@qq.com>
Thu, 7 Aug 2025 04:15:10 +0000 (12:15 +0800)
code/sdk/middleware/services/media/foundation/sample/wrapper/voice_call_volte_sample_wrapper.cpp

index 383a26c..b4c0039 100755 (executable)
@@ -1320,7 +1320,7 @@ static void AudioCaptureProcess_AI(void* arg)
     #if TTS_TEST
     FILE *fp= fopen("/user/aiRecord123.mp3","wb+");
     #else
-    FILE *fp= fopen("/user/aiRecord.bin","wb+");
+    // FILE *fp= fopen("/user/aiRecord.bin","wb+");
     #endif
 
     uint32_t record_size=0;
@@ -1347,66 +1347,34 @@ static void AudioCaptureProcess_AI(void* arg)
         }
         
         int32_t readlen = g_stream_in_uplink->ObtainBuffer(capBuf, true);
-        if(readlen > 0 && readlen <= ai_size)
+        if(readlen>0)
         {
             MEDIA_ERR_LOG("readlen %d",readlen);
-            
-            // 检查内存边界
-            if (readlen <= ai_size) {
-                send_msg_data_into_Ai_msg_queue((void *)data_buf,(uint16_t)readlen,0);
-                record_size+=readlen;
-                
-                if (fp != NULL) {
-                    fwrite(data_buf,1,readlen,fp);
-                }
-                
-                #if TTS_TEST
-                if(record_size>=1024*80)
-                {
-                    g_sample_needStop=1;
-                }
-                #else
-                if(record_size>=1024*90)
-                {
-                    g_sample_needStop=1;
-                }
-                #endif
-                
-                // 安全的内存清零
-                if (data_buf != NULL) {
-                    memset_s(data_buf,ai_size,0,ai_size);
-                }
-            } else {
-                MEDIA_ERR_LOG("readlen %d exceeds buffer size %d", readlen, ai_size);
+            send_msg_data_into_Ai_msg_queue((void *)data_buf,(uint16_t)readlen,0);
+
+            record_size+=readlen;
+
+            #if TTS_TEST
+            if (fp != NULL) {
+                fwrite(data_buf,1,readlen,fp);
             }
-        } else if (readlen < 0) {
-            MEDIA_ERR_LOG("ObtainBuffer failed with error %d", readlen);
-            // 增加错误处理和重试逻辑
-            static uint32_t error_count = 0;
-            error_count++;
+            #endif
             
-            if (error_count > 5) { // 减少错误阈值
-                MEDIA_ERR_LOG("Too many ObtainBuffer errors, stopping audio capture");
-                g_sample_needStop = 1;
-                break;
+            #if TTS_TEST
+            if(record_size>=1024*80)
+            {
+                g_sample_needStop=1;
             }
+            #else
+            if(record_size>=1024*90)
+            {
+                g_sample_needStop=1;
+            }
+            #endif
             
-            // 增加延迟避免频繁重试
-            LOS_Msleep(200); // 增加延迟时间
-            
-            // 尝试重新初始化音频流
-            if (error_count % 3 == 0) { // 更频繁的重试
-                MEDIA_ERR_LOG("Attempting to reinitialize audio stream");
-                if (g_stream_in_uplink != nullptr) {
-                    g_stream_in_uplink->Stop();
-                    LOS_Msleep(100); // 增加停止时间
-                    int ret = g_stream_in_uplink->Start();
-                    if (ret != 0) {
-                        MEDIA_ERR_LOG("Audio stream restart failed with error %d", ret);
-                        g_sample_needStop = 1;
-                        break;
-                    }
-                }
+            // 安全的内存清零
+            if (data_buf != NULL) {
+                memset_s(data_buf,ai_size,0,ai_size);
             }
         }
         
@@ -1415,10 +1383,12 @@ static void AudioCaptureProcess_AI(void* arg)
     uint8_t start_data[19]={0};
     AI_data_assembly(0,start_data,Cur_AI_Model);
     
+    #if TTS_TEST
     if (fp != NULL) {
         fclose(fp);
         fp = NULL;
     }
+    #endif
     
     send_msg_data_into_Ai_msg_queue((void *)start_data,19,2);