adapt to latest venmic again
This commit is contained in:
parent
115e436ff1
commit
7e1c3a43ee
4 changed files with 26 additions and 7 deletions
|
@ -4,7 +4,7 @@
|
||||||
* Copyright (c) 2023 Vendicated and Vencord contributors
|
* Copyright (c) 2023 Vendicated and Vencord contributors
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { 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";
|
||||||
|
@ -12,6 +12,15 @@ import { STATIC_DIR } from "shared/paths";
|
||||||
let initialized = false;
|
let initialized = false;
|
||||||
let patchBay: import("venmic").PatchBay | undefined;
|
let patchBay: import("venmic").PatchBay | undefined;
|
||||||
|
|
||||||
|
function getRendererAudioServicePid() {
|
||||||
|
return (
|
||||||
|
app
|
||||||
|
.getAppMetrics()
|
||||||
|
.find(proc => proc.name === "Audio Service")
|
||||||
|
?.pid?.toString() ?? "owo"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function obtainVenmic() {
|
function obtainVenmic() {
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
initialized = true;
|
initialized = true;
|
||||||
|
@ -26,11 +35,19 @@ function obtainVenmic() {
|
||||||
return patchBay;
|
return patchBay;
|
||||||
}
|
}
|
||||||
|
|
||||||
ipcMain.handle(IpcEvents.VIRT_MIC_LIST, () => obtainVenmic()?.list() ?? []);
|
ipcMain.handle(IpcEvents.VIRT_MIC_LIST, () => {
|
||||||
|
const audioPid = getRendererAudioServicePid();
|
||||||
|
return obtainVenmic()
|
||||||
|
?.list()
|
||||||
|
?.filter(s => s["application.process.id"] !== audioPid)
|
||||||
|
?.map(s => s["node.name"]);
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.handle(IpcEvents.VIRT_MIC_START, (_, target: string) => obtainVenmic()?.link("node.name", target, "include"));
|
||||||
|
|
||||||
ipcMain.handle(
|
ipcMain.handle(
|
||||||
IpcEvents.VIRT_MIC_START,
|
IpcEvents.VIRT_MIC_START_SYSTEM,
|
||||||
(_, target: string, mode: "include" | "exclude") => obtainVenmic()?.link(target, mode)
|
() => obtainVenmic()?.link("application.process.id", getRendererAudioServicePid(), "exclude")
|
||||||
);
|
);
|
||||||
|
|
||||||
ipcMain.handle(IpcEvents.VIRT_MIC_KILL, () => obtainVenmic()?.unlink());
|
ipcMain.handle(IpcEvents.VIRT_MIC_KILL, () => obtainVenmic()?.unlink());
|
||||||
|
|
|
@ -62,7 +62,8 @@ export const VesktopNative = {
|
||||||
/** only available on Linux. */
|
/** only available on Linux. */
|
||||||
virtmic: {
|
virtmic: {
|
||||||
list: () => invoke<string[] | null>(IpcEvents.VIRT_MIC_LIST),
|
list: () => invoke<string[] | null>(IpcEvents.VIRT_MIC_LIST),
|
||||||
start: (target: string, mode: "include" | "exclude") => invoke<void>(IpcEvents.VIRT_MIC_START, target, mode),
|
start: (target: string) => invoke<void>(IpcEvents.VIRT_MIC_START, target),
|
||||||
|
startSystem: () => invoke<void>(IpcEvents.VIRT_MIC_START_SYSTEM),
|
||||||
kill: () => invoke<void>(IpcEvents.VIRT_MIC_KILL)
|
kill: () => invoke<void>(IpcEvents.VIRT_MIC_KILL)
|
||||||
},
|
},
|
||||||
arrpc: {
|
arrpc: {
|
||||||
|
|
|
@ -83,9 +83,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.start("Chromium", "exclude");
|
await VesktopNative.virtmic.startSystem();
|
||||||
} else {
|
} else {
|
||||||
await VesktopNative.virtmic.start(v.audioSource, "include");
|
await VesktopNative.virtmic.start(v.audioSource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resolve(v);
|
resolve(v);
|
||||||
|
|
|
@ -44,6 +44,7 @@ export const enum IpcEvents {
|
||||||
|
|
||||||
VIRT_MIC_LIST = "VCD_VIRT_MIC_LIST",
|
VIRT_MIC_LIST = "VCD_VIRT_MIC_LIST",
|
||||||
VIRT_MIC_START = "VCD_VIRT_MIC_START",
|
VIRT_MIC_START = "VCD_VIRT_MIC_START",
|
||||||
|
VIRT_MIC_START_SYSTEM = "VCD_VIRT_MIC_START_ALL",
|
||||||
VIRT_MIC_KILL = "VCD_VIRT_MIC_STOP",
|
VIRT_MIC_KILL = "VCD_VIRT_MIC_STOP",
|
||||||
|
|
||||||
ARRPC_ACTIVITY = "VCD_ARRPC_ACTIVITY"
|
ARRPC_ACTIVITY = "VCD_ARRPC_ACTIVITY"
|
||||||
|
|
Reference in a new issue