mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-25 08:53:04 +02:00
Fix crashing with GainNode when the stream has no sound
This commit is contained in:
parent
18027ed1c5
commit
567770c86e
@ -4,6 +4,7 @@ import { BxEvent } from "@utils/bx-event";
|
|||||||
import { STATES } from "@utils/global";
|
import { STATES } from "@utils/global";
|
||||||
import { getPref, PrefKey } from "@utils/preferences";
|
import { getPref, PrefKey } from "@utils/preferences";
|
||||||
import { UserAgent } from "@utils/user-agent";
|
import { UserAgent } from "@utils/user-agent";
|
||||||
|
import { BxLogger } from "./bx-logger";
|
||||||
|
|
||||||
export enum InputType {
|
export enum InputType {
|
||||||
CONTROLLER = 'Controller',
|
CONTROLLER = 'Controller',
|
||||||
@ -107,11 +108,15 @@ export const BxExposed = {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const audioCtx = STATES.currentStream.audioContext!;
|
try {
|
||||||
const source = audioCtx.createMediaStreamSource(audioStream);
|
const audioCtx = STATES.currentStream.audioContext!;
|
||||||
|
const source = audioCtx.createMediaStreamSource(audioStream);
|
||||||
|
|
||||||
const gainNode = audioCtx.createGain(); // call monkey-patched createGain() in BxAudioContext
|
const gainNode = audioCtx.createGain(); // call monkey-patched createGain() in BxAudioContext
|
||||||
source.connect(gainNode).connect(audioCtx.destination);
|
source.connect(gainNode).connect(audioCtx.destination);
|
||||||
|
} catch (e) {
|
||||||
|
BxLogger.error('setupGainNode', e);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
handleControllerShortcut: ControllerShortcut.handle,
|
handleControllerShortcut: ControllerShortcut.handle,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user