mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 09:30:43 +00:00
fix: use absolute system profiler for Meet audio checks
This commit is contained in:
@@ -112,7 +112,7 @@ function setup(
|
||||
: (options.nodesInvokeResult ?? { launched: true }),
|
||||
);
|
||||
const runCommandWithTimeout = vi.fn(async (argv: string[]) => {
|
||||
if (argv[0] === "system_profiler") {
|
||||
if (argv[0] === "/usr/sbin/system_profiler") {
|
||||
return { code: 0, stdout: "BlackHole 2ch", stderr: "" };
|
||||
}
|
||||
return { code: 0, stdout: "", stderr: "" };
|
||||
@@ -506,7 +506,7 @@ describe("google-meet plugin", () => {
|
||||
expect(respond.mock.calls[0]?.[0]).toBe(true);
|
||||
expect(runCommandWithTimeout).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
["system_profiler", "SPAudioDataType"],
|
||||
["/usr/sbin/system_profiler", "SPAudioDataType"],
|
||||
{ timeoutMs: 10000 },
|
||||
);
|
||||
expect(runCommandWithTimeout).toHaveBeenNthCalledWith(
|
||||
|
||||
@@ -6,7 +6,10 @@ import {
|
||||
DEFAULT_GOOGLE_MEET_AUDIO_INPUT_COMMAND,
|
||||
DEFAULT_GOOGLE_MEET_AUDIO_OUTPUT_COMMAND,
|
||||
} from "./config.js";
|
||||
import { outputMentionsBlackHole2ch } from "./transports/chrome.js";
|
||||
import {
|
||||
GOOGLE_MEET_SYSTEM_PROFILER_COMMAND,
|
||||
outputMentionsBlackHole2ch,
|
||||
} from "./transports/chrome.js";
|
||||
|
||||
type NodeBridgeSession = {
|
||||
id: string;
|
||||
@@ -63,7 +66,10 @@ function assertBlackHoleAvailable(timeoutMs: number) {
|
||||
if (process.platform !== "darwin") {
|
||||
throw new Error("Chrome Meet transport with blackhole-2ch audio is currently macOS-only");
|
||||
}
|
||||
const result = runCommandWithTimeout(["system_profiler", "SPAudioDataType"], timeoutMs);
|
||||
const result = runCommandWithTimeout(
|
||||
[GOOGLE_MEET_SYSTEM_PROFILER_COMMAND, "SPAudioDataType"],
|
||||
timeoutMs,
|
||||
);
|
||||
const output = `${result.stdout}\n${result.stderr}`;
|
||||
if (result.code !== 0 || !outputMentionsBlackHole2ch(output)) {
|
||||
throw new Error("BlackHole 2ch audio device not found on the node.");
|
||||
|
||||
@@ -11,6 +11,8 @@ import {
|
||||
type ChromeRealtimeAudioBridgeHandle,
|
||||
} from "../realtime.js";
|
||||
|
||||
export const GOOGLE_MEET_SYSTEM_PROFILER_COMMAND = "/usr/sbin/system_profiler";
|
||||
|
||||
export function outputMentionsBlackHole2ch(output: string): boolean {
|
||||
return /\bBlackHole\s+2ch\b/i.test(output);
|
||||
}
|
||||
@@ -24,7 +26,7 @@ export async function assertBlackHole2chAvailable(params: {
|
||||
}
|
||||
|
||||
const result = await params.runtime.system.runCommandWithTimeout(
|
||||
["system_profiler", "SPAudioDataType"],
|
||||
[GOOGLE_MEET_SYSTEM_PROFILER_COMMAND, "SPAudioDataType"],
|
||||
{ timeoutMs: params.timeoutMs },
|
||||
);
|
||||
const output = `${result.stdout ?? ""}\n${result.stderr ?? ""}`;
|
||||
|
||||
Reference in New Issue
Block a user