From 3cb32337e926f8edb49a7f168bf3367f194cc835 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Wed, 24 Sep 2025 18:14:15 +0800 Subject: [PATCH] =?utf8?q?=E8=BF=98=E5=8E=9Fai=5Fmedia=5Fservice=5Fext?= =?utf8?q?=E6=96=87=E4=BB=B6=E4=B8=AD=E6=94=B9=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../zhihui/ai/media/ai_media_service_ext.cpp | 44 +------------------ 1 file changed, 2 insertions(+), 42 deletions(-) diff --git a/code/sdk/zhihui/ai/media/ai_media_service_ext.cpp b/code/sdk/zhihui/ai/media/ai_media_service_ext.cpp index 92f2b4407..1cacf170b 100644 --- a/code/sdk/zhihui/ai/media/ai_media_service_ext.cpp +++ b/code/sdk/zhihui/ai/media/ai_media_service_ext.cpp @@ -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 未运行 -- 2.17.1