






















@@ -68,6 +68,34 @@ type SpawnFn = (
6868options: { stdio: ["pipe" | "ignore", "pipe" | "ignore", "pipe" | "ignore"] },
6969) => BridgeProcess;
707071+function terminateBridgeProcess(proc: BridgeProcess, signal: NodeJS.Signals = "SIGTERM"): void {
72+if (proc.killed && signal !== "SIGKILL") {
73+return;
74+}
75+let exited = false;
76+proc.on("exit", () => {
77+exited = true;
78+});
79+try {
80+proc.kill(signal);
81+} catch {
82+return;
83+}
84+if (signal === "SIGKILL") {
85+return;
86+}
87+const timer = setTimeout(() => {
88+if (!exited) {
89+try {
90+proc.kill("SIGKILL");
91+} catch {
92+// Process may have exited after the grace check.
93+}
94+}
95+}, 1000);
96+timer.unref?.();
97+}
98+7199export type ChromeRealtimeAudioBridgeHandle = {
72100providerId: string;
73101inputCommand: string[];
@@ -549,34 +577,6 @@ export async function startCommandAgentAudioBridge(params: {
549577}),
550578);
551579552-const terminateProcess = (proc: BridgeProcess, signal: NodeJS.Signals = "SIGTERM") => {
553-if (proc.killed && signal !== "SIGKILL") {
554-return;
555-}
556-let exited = false;
557-proc.on("exit", () => {
558-exited = true;
559-});
560-try {
561-proc.kill(signal);
562-} catch {
563-return;
564-}
565-if (signal === "SIGKILL") {
566-return;
567-}
568-const timer = setTimeout(() => {
569-if (!exited) {
570-try {
571-proc.kill("SIGKILL");
572-} catch {
573-// Process may have exited after the grace check.
574-}
575-}
576-}, 1000);
577-timer.unref?.();
578-};
579-580580const stop = async () => {
581581if (stopped) {
582582return;
@@ -595,8 +595,8 @@ export async function startCommandAgentAudioBridge(params: {
595595final: true,
596596payload: { meetingSessionId: params.meetingSessionId },
597597});
598-terminateProcess(inputProcess);
599-terminateProcess(outputProcess);
598+terminateBridgeProcess(inputProcess);
599+terminateBridgeProcess(outputProcess);
600600};
601601602602const fail = (label: string) => (error: Error) => {
@@ -876,34 +876,6 @@ export async function startCommandRealtimeAudioBridge(params: {
876876lastOutputPlayableUntilMs = suppression.lastOutputPlayableUntilMs;
877877};
878878879-const terminateProcess = (proc: BridgeProcess, signal: NodeJS.Signals = "SIGTERM") => {
880-if (proc.killed && signal !== "SIGKILL") {
881-return;
882-}
883-let exited = false;
884-proc.on("exit", () => {
885-exited = true;
886-});
887-try {
888-proc.kill(signal);
889-} catch {
890-return;
891-}
892-if (signal === "SIGKILL") {
893-return;
894-}
895-const timer = setTimeout(() => {
896-if (!exited) {
897-try {
898-proc.kill("SIGKILL");
899-} catch {
900-// Process may have exited after the grace check.
901-}
902-}
903-}, 1000);
904-timer.unref?.();
905-};
906-907879const stop = async () => {
908880if (stopped) {
909881return;
@@ -917,10 +889,10 @@ export async function startCommandRealtimeAudioBridge(params: {
917889`[google-meet] realtime voice bridge close ignored: ${formatErrorMessage(error)}`,
918890);
919891}
920-terminateProcess(inputProcess);
921-terminateProcess(outputProcess);
892+terminateBridgeProcess(inputProcess);
893+terminateBridgeProcess(outputProcess);
922894if (bargeInInputProcess) {
923-terminateProcess(bargeInInputProcess);
895+terminateBridgeProcess(bargeInInputProcess);
924896}
925897};
926898@@ -970,7 +942,7 @@ export async function startCommandRealtimeAudioBridge(params: {
970942params.logger.debug?.(
971943`[google-meet] cleared realtime audio output buffer by restarting playback command`,
972944);
973-terminateProcess(previousOutput, "SIGKILL");
945+terminateBridgeProcess(previousOutput, "SIGKILL");
974946};
975947const writeOutputAudio = (audio: Buffer) => {
976948try {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。