diff --git a/src/main/virtmic.ts b/src/main/virtmic.ts index ed9d76a..963047e 100644 --- a/src/main/virtmic.ts +++ b/src/main/virtmic.ts @@ -11,6 +11,7 @@ import { STATIC_DIR } from "shared/paths"; let initialized = false; let patchBay: import("@vencord/venmic").PatchBay | undefined; +let isGlibcxxToOld = false; function getRendererAudioServicePid() { return ( @@ -27,8 +28,9 @@ function obtainVenmic() { try { const { PatchBay } = require(join(STATIC_DIR, "dist/venmic.node")) as typeof import("@vencord/venmic"); patchBay = new PatchBay(); - } catch (e) { + } catch (e: any) { console.error("Failed to initialise venmic. Make sure you're using pipewire", e); + isGlibcxxToOld = (e?.stack || e?.message || "").toLowerCase().includes("glibc"); } } @@ -42,8 +44,9 @@ ipcMain.handle(IpcEvents.VIRT_MIC_LIST, () => { .filter(s => s["application.process.id"] !== audioPid) .map(s => s["application.name"]); - // Remove duplicates - return list && [...new Set(list)]; + return list + ? { ok: true, targets: [...new Set(list)] } // Remove duplicates + : { ok: false, isGlibcxxToOld }; }); ipcMain.handle( diff --git a/src/preload/VesktopNative.ts b/src/preload/VesktopNative.ts index 1aa6e64..ca711bc 100644 --- a/src/preload/VesktopNative.ts +++ b/src/preload/VesktopNative.ts @@ -61,7 +61,8 @@ export const VesktopNative = { }, /** only available on Linux. */ virtmic: { - list: () => invoke(IpcEvents.VIRT_MIC_LIST), + list: () => + invoke<{ ok: false; isGlibcxxToOld: boolean } | { ok: true; targets: string[] }>(IpcEvents.VIRT_MIC_LIST), start: (target: string) => invoke(IpcEvents.VIRT_MIC_START, target), startSystem: () => invoke(IpcEvents.VIRT_MIC_START_SYSTEM), stop: () => invoke(IpcEvents.VIRT_MIC_STOP) diff --git a/src/renderer/components/ScreenSharePicker.tsx b/src/renderer/components/ScreenSharePicker.tsx index e4bed52..bf141ec 100644 --- a/src/renderer/components/ScreenSharePicker.tsx +++ b/src/renderer/components/ScreenSharePicker.tsx @@ -240,19 +240,30 @@ function AudioSourcePickerLinux({ audioSource?: string; setAudioSource(s: string): void; }) { - const [sources, _, loading] = useAwaiter(() => VesktopNative.virtmic.list(), { fallbackValue: [] }); - const allSources = sources ? ["None", "Entire System", ...sources] : null; + const [sources, _, loading] = useAwaiter(() => VesktopNative.virtmic.list(), { + fallbackValue: { ok: true, targets: [] } + }); + const allSources = sources.ok ? ["None", "Entire System", ...sources.targets] : null; return (
Audio {loading && Loading Audio sources...} - {allSources === null && ( - - Failed to retrieve Audio Sources. If you would like to stream with Audio, make sure you're using - Pipewire, not Pulseaudio - - )} + {!sources.ok && + (sources.isGlibcxxToOld ? ( + + Failed to retrieve Audio Sources because your c++ library is too old to run venmic. If you would + like to stream with Audio, see{" "} + + this guide + + + ) : ( + + Failed to retrieve Audio Sources. If you would like to stream with Audio, make sure you're using + Pipewire, not Pulseaudio + + ))} {allSources && (