readCnt, timeStamp.time.tv_sec, timeStamp.time.tv_nsec);
}
}
- MEDIA_INFO_LOG("audioCap Read readCnt = %d, size = %d", readCnt, ret);
+ // MEDIA_INFO_LOG("audioCap Read readCnt = %d, size = %d", readCnt, ret);
}
if (g_audioSourceProcessInput.audioFormat == OPUS) {
AudioCapturerOggCtxDeInit();
static char g_vad_live_path[256] = "/user/vad_live.pcm";
static int g_vad_prev_status = -1;
+// 尾随线程,持续从文件中读取数据并喂给 VAD
static void *VadTailThread(void *arg)
{
printf("VAD TailThread\n");
return NULL;
}
+/* 确保父目录存在 */
static void EnsureParentDir(const char *file_path)
{
if (file_path == NULL) {
printf("=== 停止 VAD 实时录音 ===\n");
- /* 1) 停止尾随线程 */
- if (g_vad_live_running) {
- g_vad_live_running = false;
- if (g_vad_tail_thread != NULL) {
- MediaThreadJoin(&g_vad_tail_thread);
- g_vad_tail_thread = NULL;
- }
- }
-
- /* 2) 停止系统录音 */
+ /* 1) 先停止系统录音,减少文件追加,便于尾随线程退出 */
+ printf("VAD 停止系统录音\n");
{
const char *stopArg = "stop";
(void)AudioCaptureSample(1, &stopArg);
}
+ /* 2) 通知尾随线程退出(不阻塞等待) */
+ printf("VAD 停止尾随线程\n");
+ g_vad_live_running = false;
+ g_vad_tail_thread = NULL;
+
printf("VAD 实时录音已停止\n");
return ERRCODE_SUCC;
}