feat(screenshare): add workaround
This commit is contained in:
parent
4d82a6f41d
commit
95acf9cdb4
3 changed files with 57 additions and 14 deletions
|
@ -4,11 +4,14 @@
|
||||||
* Copyright (c) 2023 Vendicated and Vencord contributors
|
* Copyright (c) 2023 Vendicated and Vencord contributors
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { PatchBay } from "@vencord/venmic";
|
||||||
import { app, ipcMain } from "electron";
|
import { app, ipcMain } from "electron";
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
import { IpcEvents } from "shared/IpcEvents";
|
import { IpcEvents } from "shared/IpcEvents";
|
||||||
import { STATIC_DIR } from "shared/paths";
|
import { STATIC_DIR } from "shared/paths";
|
||||||
|
|
||||||
|
type LinkData = Parameters<PatchBay["link"]>[0];
|
||||||
|
|
||||||
let initialized = false;
|
let initialized = false;
|
||||||
let patchBay: import("@vencord/venmic").PatchBay | undefined;
|
let patchBay: import("@vencord/venmic").PatchBay | undefined;
|
||||||
let isGlibcxxToOld = false;
|
let isGlibcxxToOld = false;
|
||||||
|
@ -51,17 +54,35 @@ ipcMain.handle(IpcEvents.VIRT_MIC_LIST, () => {
|
||||||
: { ok: false, isGlibcxxToOld };
|
: { ok: false, isGlibcxxToOld };
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.handle(IpcEvents.VIRT_MIC_START, (_, targets: string[]) =>
|
ipcMain.handle(IpcEvents.VIRT_MIC_START, (_, targets: string[], workaround?: boolean) => {
|
||||||
obtainVenmic()?.link({
|
const data: LinkData = {
|
||||||
include: targets.map(target => ({ key: "application.name", value: target })),
|
include: targets.map(target => ({ key: "application.name", value: target })),
|
||||||
exclude: [{ key: "application.process.id", value: getRendererAudioServicePid() }]
|
exclude: [{ key: "application.process.id", value: getRendererAudioServicePid() }]
|
||||||
})
|
};
|
||||||
);
|
|
||||||
|
|
||||||
ipcMain.handle(IpcEvents.VIRT_MIC_START_SYSTEM, () =>
|
if (workaround) {
|
||||||
obtainVenmic()?.link({
|
data.workaround = [
|
||||||
|
{ key: "application.process.id", value: getRendererAudioServicePid() },
|
||||||
|
{ key: "media.name", value: "RecordStream" }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return obtainVenmic()?.link(data);
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.handle(IpcEvents.VIRT_MIC_START_SYSTEM, (_, workaround?: boolean) => {
|
||||||
|
const data: LinkData = {
|
||||||
exclude: [{ key: "application.process.id", value: getRendererAudioServicePid() }]
|
exclude: [{ key: "application.process.id", value: getRendererAudioServicePid() }]
|
||||||
})
|
};
|
||||||
);
|
|
||||||
|
if (workaround) {
|
||||||
|
data.workaround = [
|
||||||
|
{ key: "application.process.id", value: getRendererAudioServicePid() },
|
||||||
|
{ key: "media.name", value: "RecordStream" }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return obtainVenmic()?.link(data);
|
||||||
|
});
|
||||||
|
|
||||||
ipcMain.handle(IpcEvents.VIRT_MIC_STOP, () => obtainVenmic()?.unlink());
|
ipcMain.handle(IpcEvents.VIRT_MIC_STOP, () => obtainVenmic()?.unlink());
|
||||||
|
|
|
@ -63,8 +63,8 @@ export const VesktopNative = {
|
||||||
virtmic: {
|
virtmic: {
|
||||||
list: () =>
|
list: () =>
|
||||||
invoke<{ ok: false; isGlibcxxToOld: boolean } | { ok: true; targets: string[] }>(IpcEvents.VIRT_MIC_LIST),
|
invoke<{ ok: false; isGlibcxxToOld: boolean } | { ok: true; targets: string[] }>(IpcEvents.VIRT_MIC_LIST),
|
||||||
start: (targets: string[]) => invoke<void>(IpcEvents.VIRT_MIC_START, targets),
|
start: (targets: string[], workaround?: boolean) => invoke<void>(IpcEvents.VIRT_MIC_START, targets, workaround),
|
||||||
startSystem: () => invoke<void>(IpcEvents.VIRT_MIC_START_SYSTEM),
|
startSystem: (workaround?: boolean) => invoke<void>(IpcEvents.VIRT_MIC_START_SYSTEM, workaround),
|
||||||
stop: () => invoke<void>(IpcEvents.VIRT_MIC_STOP)
|
stop: () => invoke<void>(IpcEvents.VIRT_MIC_STOP)
|
||||||
},
|
},
|
||||||
arrpc: {
|
arrpc: {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
import "./screenSharePicker.css";
|
import "./screenSharePicker.css";
|
||||||
|
|
||||||
import { closeModal, Modals, openModal, useAwaiter } from "@vencord/types/utils";
|
import { closeModal, Margins, Modals, openModal, useAwaiter } from "@vencord/types/utils";
|
||||||
import { findStoreLazy, onceReady } from "@vencord/types/webpack";
|
import { findStoreLazy, onceReady } from "@vencord/types/webpack";
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
|
@ -36,6 +36,7 @@ interface StreamSettings {
|
||||||
fps: StreamFps;
|
fps: StreamFps;
|
||||||
audio: boolean;
|
audio: boolean;
|
||||||
audioSource?: string;
|
audioSource?: string;
|
||||||
|
workaround?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface StreamPick extends StreamSettings {
|
export interface StreamPick extends StreamSettings {
|
||||||
|
@ -107,9 +108,9 @@ export function openScreenSharePicker(screens: Source[], skipPicker: boolean) {
|
||||||
didSubmit = true;
|
didSubmit = true;
|
||||||
if (v.audioSource && v.audioSource !== "None") {
|
if (v.audioSource && v.audioSource !== "None") {
|
||||||
if (v.audioSource === "Entire System") {
|
if (v.audioSource === "Entire System") {
|
||||||
await VesktopNative.virtmic.startSystem();
|
await VesktopNative.virtmic.startSystem(v.workaround);
|
||||||
} else {
|
} else {
|
||||||
await VesktopNative.virtmic.start([v.audioSource]);
|
await VesktopNative.virtmic.start([v.audioSource], v.workaround);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resolve(v);
|
resolve(v);
|
||||||
|
@ -228,7 +229,9 @@ function StreamSettings({
|
||||||
{isLinux && (
|
{isLinux && (
|
||||||
<AudioSourcePickerLinux
|
<AudioSourcePickerLinux
|
||||||
audioSource={settings.audioSource}
|
audioSource={settings.audioSource}
|
||||||
|
workaround={settings.workaround}
|
||||||
setAudioSource={source => setSettings(s => ({ ...s, audioSource: source }))}
|
setAudioSource={source => setSettings(s => ({ ...s, audioSource: source }))}
|
||||||
|
setWorkaround={workaround => setSettings(s => ({ ...s, workaround: workaround }))}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Card>
|
</Card>
|
||||||
|
@ -238,10 +241,14 @@ function StreamSettings({
|
||||||
|
|
||||||
function AudioSourcePickerLinux({
|
function AudioSourcePickerLinux({
|
||||||
audioSource,
|
audioSource,
|
||||||
setAudioSource
|
workaround,
|
||||||
|
setAudioSource,
|
||||||
|
setWorkaround
|
||||||
}: {
|
}: {
|
||||||
audioSource?: string;
|
audioSource?: string;
|
||||||
|
workaround?: boolean;
|
||||||
setAudioSource(s: string): void;
|
setAudioSource(s: string): void;
|
||||||
|
setWorkaround(b: boolean): void;
|
||||||
}) {
|
}) {
|
||||||
const [sources, _, loading] = useAwaiter(() => VesktopNative.virtmic.list(), {
|
const [sources, _, loading] = useAwaiter(() => VesktopNative.virtmic.list(), {
|
||||||
fallbackValue: { ok: true, targets: [] }
|
fallbackValue: { ok: true, targets: [] }
|
||||||
|
@ -276,6 +283,21 @@ function AudioSourcePickerLinux({
|
||||||
serialize={String}
|
serialize={String}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
<Forms.FormDivider className={Margins.top16 + " " + Margins.bottom16} />
|
||||||
|
|
||||||
|
<Switch
|
||||||
|
onChange={setWorkaround}
|
||||||
|
value={workaround ?? false}
|
||||||
|
note={
|
||||||
|
<>
|
||||||
|
Work around an issue that causes the microphone to be shared instead of the correct audio. Only
|
||||||
|
enable if you're experiencing this issue.
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Microphone Workaround
|
||||||
|
</Switch>
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue