(session: SessionState)
| 82 | } |
| 83 | |
| 84 | async function waitForHostSystemAudioProbeStatus(session: SessionState): Promise<AudioProbeResult> { |
| 85 | const deadline = Date.now() + 5_000; |
| 86 | while (Date.now() < deadline) { |
| 87 | const status = await readHostSystemAudioProbeStatus(session); |
| 88 | if (status) return status; |
| 89 | const exit = await Promise.race([ |
| 90 | session.audioProbe?.wait.then( |
| 91 | (result) => result, |
| 92 | (error: unknown) => error, |
| 93 | ), |
| 94 | sleep(100).then(() => undefined), |
| 95 | ]); |
| 96 | if (exit instanceof Error) throw exit; |
| 97 | if (exit) { |
| 98 | const result = exit as { stdout?: string; stderr?: string; exitCode?: number }; |
| 99 | const message = |
| 100 | result.stderr?.trim() || |
| 101 | result.stdout?.trim() || |
| 102 | `host audio probe helper exited with code ${result.exitCode ?? 1}`; |
| 103 | throw new AppError('COMMAND_FAILED', `failed to start host audio probe: ${message}`); |
| 104 | } |
| 105 | } |
| 106 | throw new AppError('COMMAND_FAILED', 'failed to start host audio probe'); |
| 107 | } |
| 108 | |
| 109 | async function readHostSystemAudioProbeStatus( |
| 110 | session: SessionState, |
no test coverage detected