feat: ship Wave 5-6 multi-surface hygiene, optimization, and bug fixes

This commit is contained in:
Yun Chan 2026-11-14 11:51:41 +09:00
parent 01ef3293cf
commit 66b6b45ba9
399 changed files with 17828 additions and 11330 deletions

View file

@ -4,8 +4,8 @@ import { ipcMain } from 'electron'
import { IPC_CHANNELS } from '@d3ro/core/ipc-channels'
import { ipcSuccess, ipcError, ErrorCode } from '@d3ro/core/errors'
import { getAudioCaptureService, calculateRMS, type CaptureLease } from '../services/AudioCaptureService'
import { getMainWindow } from '../windows/WindowManager'
import { configGet, configSet } from '../services/ConfigService'
import { safeSendToRenderer } from './renderer-broadcast'
import type { SetDeviceParams, TestDeviceParams } from '@d3ro/core/types'
let testTimer: ReturnType<typeof setTimeout> | null = null
@ -44,6 +44,10 @@ async function stopAudioTest(): Promise<void> {
await lease?.release().catch(() => { /* ignore */ })
}
export async function disposeAudioHandlers(): Promise<void> {
await stopAudioTest()
}
export function registerAudioHandlers(): void {
ipcMain.handle(IPC_CHANNELS.AUDIO.GET_DEVICES, async () => {
try {
@ -103,19 +107,13 @@ export function registerAudioHandlers(): void {
// level 0은 "무음/초기화 중"일 뿐 종료가 아님 — 종료는 done:true로만 알린다.
testLevelInterval = setInterval(() => {
const level = testLastRms > 0 ? Math.min(1.0, Math.pow(testLastRms, 0.28)) : 0
const win = getMainWindow()
if (win && !win.isDestroyed()) {
win.webContents.send(IPC_CHANNELS.AUDIO.TEST_LEVEL, { level, done: false })
}
safeSendToRenderer(IPC_CHANNELS.AUDIO.TEST_LEVEL, { level, done: false })
}, 100)
// durationMs(기본 5초) 후 자동 중지
testTimer = setTimeout(() => {
void stopAudioTest()
const win = getMainWindow()
if (win && !win.isDestroyed()) {
win.webContents.send(IPC_CHANNELS.AUDIO.TEST_LEVEL, { level: 0, done: true })
}
safeSendToRenderer(IPC_CHANNELS.AUDIO.TEST_LEVEL, { level: 0, done: true })
}, durationMs)
return ipcSuccess({ averageLevel: 0, peakLevel: 0, hasAudio: true })
@ -131,10 +129,7 @@ export function registerAudioHandlers(): void {
// 테스트 수동 중지 (STOP 버튼)
ipcMain.handle(IPC_CHANNELS.AUDIO.STOP_TEST, async () => {
await stopAudioTest()
const win = getMainWindow()
if (win && !win.isDestroyed()) {
win.webContents.send(IPC_CHANNELS.AUDIO.TEST_LEVEL, { level: 0, done: true })
}
safeSendToRenderer(IPC_CHANNELS.AUDIO.TEST_LEVEL, { level: 0, done: true })
return ipcSuccess(undefined)
})
}