根因: 每次按键时 Pa_OpenStream() + Pa_StartStream() 耗时 3-4s, stop() 时又 Pa_CloseStream() + Pa_Terminate() 销毁流。 优化: - AudioCapture::start() 复用已打开的流(参数匹配时跳过 OpenStream) - AudioCapture::stop() 只 Pa_StopStream(),保留流 - 新增 stopAndClose() 彻底关闭流(析构和服务停止时使用) - VoiceInputService::start() 时预打开音频流再立即 stop() → 后续 hotkey start() 只需 Pa_StartStream() (<100ms) 效果: 按键到录音延迟从 3-4s 降至 <100ms Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| audio_capture.cpp | ||
| audio_capture.h | ||
| audio_decoder.cpp | ||
| audio_decoder.h | ||
| audio_ring_buffer.cpp | ||
| audio_ring_buffer.h | ||
| streaming_audio_writer.cpp | ||
| streaming_audio_writer.h | ||