Settings 열기 속도 개선: 오디오 디바이스 캐싱

This commit is contained in:
Yun Chan 2026-04-05 13:17:48 +09:00
parent 4e23622c44
commit 8bd9d11ecd

View file

@ -56,6 +56,7 @@ class AudioCaptureService extends EventEmitter {
private _state: CaptureState = 'idle'
private _currentDevice: AudioDevice | null = null
private _refCount = 0
private _cachedDevices: AudioDevice[] | null = null
private _soxProcess: ChildProcess | null = null
private _stream: Readable | null = null
private _levelInterval: ReturnType<typeof setInterval> | null = null
@ -221,6 +222,9 @@ class AudioCaptureService extends EventEmitter {
}
async getDevices(): Promise<AudioDevice[]> {
// 캐싱: PowerShell 호출이 느리므로 한번만 실행
if (this._cachedDevices) return this._cachedDevices
const devices: AudioDevice[] = [
{ deviceId: 'default', label: '시스템 기본 마이크', isDefault: true },
]
@ -256,6 +260,7 @@ class AudioCaptureService extends EventEmitter {
logger.warn(`Failed to enumerate audio devices via PowerShell: ${err instanceof Error ? err.message : String(err)}`)
}
this._cachedDevices = devices
logger.debug(`Found ${devices.length} audio device(s)`)
return devices
}