diff --git a/package.json b/package.json index 1de1c68..04b2132 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "arrpc": "github:OpenAsar/arrpc#98879cae0565e6fce34e4cb6f544bf42c6a7e7c8" }, "optionalDependencies": { - "@vencord/venmic": "^3.2.3" + "@vencord/venmic": "^3.3.2" }, "devDependencies": { "@fal-works/esbuild-plugin-global-externals": "^2.1.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cf83791..9f93b75 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,8 +11,8 @@ dependencies: optionalDependencies: '@vencord/venmic': - specifier: ^3.2.3 - version: 3.2.3 + specifier: ^3.3.2 + version: 3.3.2 devDependencies: '@fal-works/esbuild-plugin-global-externals': @@ -793,8 +793,8 @@ packages: type-fest: 3.13.1 dev: true - /@vencord/venmic@3.2.3: - resolution: {integrity: sha512-mnpAa5aFRkMQhoeYjkygPY+U+/b7Nh55HekchWzl2y5RNHpCxooGANTcw4L80JoCiL+AYRUg8BQU31L7fFQcPw==} + /@vencord/venmic@3.3.2: + resolution: {integrity: sha512-fwGr5v+Xe4EisKxxhTDlUDamBGlBzSK3+yYZH/7d9ui1j8Q78wCbE1iP8MnDjBvV2kIKn/xV/84wjt9iQvDkFw==} engines: {node: '>=14.15'} os: [linux] requiresBuild: true diff --git a/src/main/venmic.ts b/src/main/venmic.ts index fcc40de..c6f9d44 100644 --- a/src/main/venmic.ts +++ b/src/main/venmic.ts @@ -4,11 +4,14 @@ * Copyright (c) 2023 Vendicated and Vencord contributors */ +import type { PatchBay } from "@vencord/venmic"; import { app, ipcMain } from "electron"; import { join } from "path"; import { IpcEvents } from "shared/IpcEvents"; import { STATIC_DIR } from "shared/paths"; +type LinkData = Parameters[0]; + let initialized = false; let patchBay: import("@vencord/venmic").PatchBay | undefined; let isGlibcxxToOld = false; @@ -51,17 +54,39 @@ ipcMain.handle(IpcEvents.VIRT_MIC_LIST, () => { : { ok: false, isGlibcxxToOld }; }); -ipcMain.handle(IpcEvents.VIRT_MIC_START, (_, targets: string[]) => - obtainVenmic()?.link({ - include: targets.map(target => ({ key: "application.name", value: target })), - exclude: [{ key: "application.process.id", value: getRendererAudioServicePid() }] - }) -); +ipcMain.handle(IpcEvents.VIRT_MIC_START, (_, targets: string[], workaround?: boolean) => { + const pid = getRendererAudioServicePid(); -ipcMain.handle(IpcEvents.VIRT_MIC_START_SYSTEM, () => - obtainVenmic()?.link({ - exclude: [{ key: "application.process.id", value: getRendererAudioServicePid() }] - }) -); + const data: LinkData = { + include: targets.map(target => ({ key: "application.name", value: target })), + exclude: [{ key: "application.process.id", value: pid }] + }; + + if (workaround) { + data.workaround = [ + { key: "application.process.id", value: pid }, + { key: "media.name", value: "RecordStream" } + ]; + } + + return obtainVenmic()?.link(data); +}); + +ipcMain.handle(IpcEvents.VIRT_MIC_START_SYSTEM, (_, workaround?: boolean) => { + const pid = getRendererAudioServicePid(); + + const data: LinkData = { + exclude: [{ key: "application.process.id", value: pid }] + }; + + if (workaround) { + data.workaround = [ + { key: "application.process.id", value: pid }, + { key: "media.name", value: "RecordStream" } + ]; + } + + return obtainVenmic()?.link(data); +}); ipcMain.handle(IpcEvents.VIRT_MIC_STOP, () => obtainVenmic()?.unlink()); diff --git a/src/preload/VesktopNative.ts b/src/preload/VesktopNative.ts index 172d2c2..ead4d63 100644 --- a/src/preload/VesktopNative.ts +++ b/src/preload/VesktopNative.ts @@ -64,8 +64,8 @@ export const VesktopNative = { virtmic: { list: () => invoke<{ ok: false; isGlibcxxToOld: boolean } | { ok: true; targets: string[] }>(IpcEvents.VIRT_MIC_LIST), - start: (targets: string[]) => invoke(IpcEvents.VIRT_MIC_START, targets), - startSystem: () => invoke(IpcEvents.VIRT_MIC_START_SYSTEM), + start: (targets: string[], workaround?: boolean) => invoke(IpcEvents.VIRT_MIC_START, targets, workaround), + startSystem: (workaround?: boolean) => invoke(IpcEvents.VIRT_MIC_START_SYSTEM, workaround), stop: () => invoke(IpcEvents.VIRT_MIC_STOP) }, arrpc: { diff --git a/src/renderer/components/ScreenSharePicker.tsx b/src/renderer/components/ScreenSharePicker.tsx index 320c52c..9842afe 100644 --- a/src/renderer/components/ScreenSharePicker.tsx +++ b/src/renderer/components/ScreenSharePicker.tsx @@ -6,7 +6,7 @@ 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 { Button, @@ -36,6 +36,7 @@ interface StreamSettings { fps: StreamFps; audio: boolean; audioSource?: string; + workaround?: boolean; } export interface StreamPick extends StreamSettings { @@ -107,9 +108,9 @@ export function openScreenSharePicker(screens: Source[], skipPicker: boolean) { didSubmit = true; if (v.audioSource && v.audioSource !== "None") { if (v.audioSource === "Entire System") { - await VesktopNative.virtmic.startSystem(); + await VesktopNative.virtmic.startSystem(v.workaround); } else { - await VesktopNative.virtmic.start([v.audioSource]); + await VesktopNative.virtmic.start([v.audioSource], v.workaround); } } resolve(v); @@ -228,7 +229,9 @@ function StreamSettings({ {isLinux && ( setSettings(s => ({ ...s, audioSource: source }))} + setWorkaround={workaround => setSettings(s => ({ ...s, workaround: workaround }))} /> )} @@ -238,10 +241,14 @@ function StreamSettings({ function AudioSourcePickerLinux({ audioSource, - setAudioSource + workaround, + setAudioSource, + setWorkaround }: { audioSource?: string; + workaround?: boolean; setAudioSource(s: string): void; + setWorkaround(b: boolean): void; }) { const [sources, _, loading] = useAwaiter(() => VesktopNative.virtmic.list(), { fallbackValue: { ok: true, targets: [] } @@ -276,6 +283,21 @@ function AudioSourcePickerLinux({ serialize={String} /> )} + + + + + 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 + ); }