screenaudio: show better error if glibcxx too old

This commit is contained in:
Vendicated 2023-10-27 00:27:35 +02:00
parent 0cad71f6ae
commit 886d02f7c3
No known key found for this signature in database
GPG key ID: D66986BAF75ECF18
3 changed files with 27 additions and 12 deletions

View file

@ -11,6 +11,7 @@ import { STATIC_DIR } from "shared/paths";
let initialized = false; let initialized = false;
let patchBay: import("@vencord/venmic").PatchBay | undefined; let patchBay: import("@vencord/venmic").PatchBay | undefined;
let isGlibcxxToOld = false;
function getRendererAudioServicePid() { function getRendererAudioServicePid() {
return ( return (
@ -27,8 +28,9 @@ function obtainVenmic() {
try { try {
const { PatchBay } = require(join(STATIC_DIR, "dist/venmic.node")) as typeof import("@vencord/venmic"); const { PatchBay } = require(join(STATIC_DIR, "dist/venmic.node")) as typeof import("@vencord/venmic");
patchBay = new PatchBay(); patchBay = new PatchBay();
} catch (e) { } catch (e: any) {
console.error("Failed to initialise venmic. Make sure you're using pipewire", e); 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) .filter(s => s["application.process.id"] !== audioPid)
.map(s => s["application.name"]); .map(s => s["application.name"]);
// Remove duplicates return list
return list && [...new Set(list)]; ? { ok: true, targets: [...new Set(list)] } // Remove duplicates
: { ok: false, isGlibcxxToOld };
}); });
ipcMain.handle( ipcMain.handle(

View file

@ -61,7 +61,8 @@ export const VesktopNative = {
}, },
/** only available on Linux. */ /** only available on Linux. */
virtmic: { virtmic: {
list: () => invoke<string[] | null>(IpcEvents.VIRT_MIC_LIST), list: () =>
invoke<{ ok: false; isGlibcxxToOld: boolean } | { ok: true; targets: string[] }>(IpcEvents.VIRT_MIC_LIST),
start: (target: string) => invoke<void>(IpcEvents.VIRT_MIC_START, target), start: (target: string) => invoke<void>(IpcEvents.VIRT_MIC_START, target),
startSystem: () => invoke<void>(IpcEvents.VIRT_MIC_START_SYSTEM), startSystem: () => invoke<void>(IpcEvents.VIRT_MIC_START_SYSTEM),
stop: () => invoke<void>(IpcEvents.VIRT_MIC_STOP) stop: () => invoke<void>(IpcEvents.VIRT_MIC_STOP)

View file

@ -240,19 +240,30 @@ function AudioSourcePickerLinux({
audioSource?: string; audioSource?: string;
setAudioSource(s: string): void; setAudioSource(s: string): void;
}) { }) {
const [sources, _, loading] = useAwaiter(() => VesktopNative.virtmic.list(), { fallbackValue: [] }); const [sources, _, loading] = useAwaiter(() => VesktopNative.virtmic.list(), {
const allSources = sources ? ["None", "Entire System", ...sources] : null; fallbackValue: { ok: true, targets: [] }
});
const allSources = sources.ok ? ["None", "Entire System", ...sources.targets] : null;
return ( return (
<section> <section>
<Forms.FormTitle>Audio</Forms.FormTitle> <Forms.FormTitle>Audio</Forms.FormTitle>
{loading && <Forms.FormTitle>Loading Audio sources...</Forms.FormTitle>} {loading && <Forms.FormTitle>Loading Audio sources...</Forms.FormTitle>}
{allSources === null && ( {!sources.ok &&
<Forms.FormTitle> (sources.isGlibcxxToOld ? (
Failed to retrieve Audio Sources. If you would like to stream with Audio, make sure you're using <Forms.FormText>
Pipewire, not Pulseaudio Failed to retrieve Audio Sources because your c++ library is too old to run venmic. If you would
</Forms.FormTitle> like to stream with Audio, see{" "}
)} <a href="https://gist.github.com/Vendicated/b655044ffbb16b2716095a448c6d827a" target="_blank">
this guide
</a>
</Forms.FormText>
) : (
<Forms.FormText>
Failed to retrieve Audio Sources. If you would like to stream with Audio, make sure you're using
Pipewire, not Pulseaudio
</Forms.FormText>
))}
{allSources && ( {allSources && (
<Select <Select