还原ai_media_service_ext文件中改动 2389/1 2389/head 2390/target/1
authorluozheng <1732036298@qq.com>
Wed, 24 Sep 2025 10:14:15 +0000 (18:14 +0800)
committerluozheng <1732036298@qq.com>
Wed, 24 Sep 2025 10:14:15 +0000 (18:14 +0800)
code/sdk/zhihui/ai/media/ai_media_service_ext.cpp

index 92f2b44..1cacf17 100644 (file)
@@ -45,8 +45,8 @@ using namespace::Audio;
 const int32_t NUMBER_BASE = 10;
 const int32_t CHANNEL_COUNT = 2;
 const int32_t SAMPLERATE_16000 = 16000;
-const uint32_t AI_VOICE_BUFFER_SIZE = 0x1000;  // 2KB buffer for AI voice
-const uint32_t AI_VOICE_QUEUE_SIZE = 20;      // 队列大小
+const uint32_t AI_VOICE_BUFFER_SIZE = 0x800;  // 2KB buffer for AI voice
+const uint32_t AI_VOICE_QUEUE_SIZE = 10; 
 
 // 定义音频数据回调函数类型
 
@@ -840,45 +840,6 @@ static void ExampleAIVoiceDataCallback(const uint8_t* data, uint32_t size, void*
  * @param size 音频数据大小
  * @return 0 成功,-1 失败
  */
-#ifdef BOARD_LEINIAO
-int32_t AI_WriteAudioData(const uint8_t* data, uint32_t size)
-{
-    if (data == nullptr || size == 0) {
-        MEDIA_ERR_LOG("Invalid audio data parameters");
-        return -1;
-    }
-    AI_WRITE:
-    if(g_aiVoiceContext->interruptFlag)
-    return -1;
-    // 获取全局互斥锁(自动初始化)
-    MediaMutexHandle mutex = GetGlobalMutex();
-    if (mutex == nullptr) {
-        MEDIA_ERR_LOG("Failed to get global mutex");
-        return -1;
-    }
-    
-    // 检查AI语音上下文是否存在
-    MediaMutexLock(mutex);
-    if (g_aiVoiceContext == nullptr) {
-        MEDIA_ERR_LOG("AI voice context is null, please start AI voice first");
-        MediaMutexUnLock(mutex);
-        return -1;
-    }
-    MediaMutexUnLock(g_aiVoiceContextMutex);
-
-    // 写入音频数据到输出流
-    int32_t ret = AudioStreamOutStreamWrite(data, size);
-    if (ret != 0) {
-        // MEDIA_ERR_LOG("Failed to write audio data to output stream, ret=%d", ret);
-        // return -1;
-        usleep(30*size);
-        goto AI_WRITE;
-    }
-    
-    // MEDIA_INFO_LOG("Successfully wrote %u bytes of audio data to output stream", size);
-    return 0;
-}
-#else
 int32_t AI_WriteAudioData(const uint8_t* data, uint32_t size)
 {
     if (data == nullptr || size == 0) {
@@ -917,7 +878,6 @@ int32_t AI_WriteAudioData(const uint8_t* data, uint32_t size)
     // MEDIA_INFO_LOG("Successfully wrote %u bytes of audio data to output stream", size);
     return 0;
 }
-#endif
 /**
  * @brief 检查AI语音服务是否正在运行
  * @return true 正在运行,false 未运行