MCPcopy Index your code
hub / github.com/callstack/agent-device / waitForHostSystemAudioProbeStatus

Function waitForHostSystemAudioProbeStatus

src/daemon/audio-probe.ts:84–107  ·  view source on GitHub ↗
(session: SessionState)

Source from the content-addressed store, hash-verified

82}
83
84async 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
109async function readHostSystemAudioProbeStatus(
110 session: SessionState,

Callers 1

Calls 2

sleepFunction · 0.90

Tested by

no test coverage detected