fix(voice): stop mic-test ref stealing, unblock action queue, keep tail audio, and move context/LLM routing behind ports and pure policies
This commit is contained in:
parent
2cd462333f
commit
2f94d24c99
13 changed files with 1672 additions and 353 deletions
|
|
@ -3,7 +3,7 @@
|
|||
import { ipcMain } from 'electron'
|
||||
import { IPC_CHANNELS } from '@d3ro/core/ipc-channels'
|
||||
import { ipcSuccess, ipcError, ErrorCode } from '@d3ro/core/errors'
|
||||
import { getAudioCaptureService, calculateRMS } from '../services/AudioCaptureService'
|
||||
import { getAudioCaptureService, calculateRMS, type CaptureLease } from '../services/AudioCaptureService'
|
||||
import { getMainWindow } from '../windows/WindowManager'
|
||||
import { configGet, configSet } from '../services/ConfigService'
|
||||
import type { SetDeviceParams } from '@d3ro/core/types'
|
||||
|
|
@ -12,6 +12,11 @@ let testTimer: ReturnType<typeof setTimeout> | null = null
|
|||
let testAudioHandler: ((payload: { buffer: Buffer; timestamp: number }) => void) | null = null
|
||||
let testLevelInterval: ReturnType<typeof setInterval> | null = null
|
||||
let testLastRms = 0
|
||||
/**
|
||||
* 테스트가 실제로 잡은 캡처 참조. 테스트가 돌고 있지 않을 때 stop() 을 부르면 회의·자막·받아쓰기가
|
||||
* 잡고 있는 참조를 빼앗아 그쪽 마이크가 조용히 끊긴다 — 테스트는 자기 임대만 놓는다.
|
||||
*/
|
||||
let testLease: CaptureLease | null = null
|
||||
|
||||
function stopAudioTest(): void {
|
||||
const service = getAudioCaptureService()
|
||||
|
|
@ -28,7 +33,9 @@ function stopAudioTest(): void {
|
|||
testTimer = null
|
||||
}
|
||||
testLastRms = 0
|
||||
service.stop().catch(() => { /* ignore */ })
|
||||
const lease = testLease
|
||||
testLease = null
|
||||
lease?.release().catch(() => { /* ignore */ })
|
||||
}
|
||||
|
||||
export function registerAudioHandlers(): void {
|
||||
|
|
@ -62,7 +69,7 @@ export function registerAudioHandlers(): void {
|
|||
stopAudioTest()
|
||||
|
||||
const service = getAudioCaptureService()
|
||||
await service.start()
|
||||
testLease = await service.acquire()
|
||||
|
||||
// 오디오 데이터에서 RMS 추적
|
||||
testAudioHandler = (payload: { buffer: Buffer; timestamp: number }) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue