Fix Race risks if process_audio is called concurrently.

This commit is contained in:
Xin Wang
2026-02-06 08:26:56 +08:00
parent 26458faa6c
commit 0576231d8d

View File

@@ -111,6 +111,7 @@ class DuplexPipeline:
max_buffer_seconds = settings.max_audio_buffer_seconds if hasattr(settings, "max_audio_buffer_seconds") else 30
self._max_audio_buffer_bytes = int(settings.sample_rate * 2 * max_buffer_seconds)
self._last_vad_status: str = "Silence"
self._process_lock = asyncio.Lock()
# Interruption handling
self._interrupt_event = asyncio.Event()
@@ -208,6 +209,7 @@ class DuplexPipeline:
return
try:
async with self._process_lock:
# 1. Process through VAD
vad_result = self.vad_processor.process(pcm_bytes, settings.chunk_size_ms)