Improve Venmic Usability (#504)
This commit is contained in:
@@ -331,9 +331,13 @@ function AudioSourcePickerLinux({
|
||||
setOnlyDefaultSpeakers(b: boolean): void;
|
||||
}) {
|
||||
const [sources, _, loading] = useAwaiter(() => VesktopNative.virtmic.list(), {
|
||||
fallbackValue: { ok: true, targets: [] }
|
||||
fallbackValue: { ok: true, targets: [], hasPipewirePulse: true }
|
||||
});
|
||||
|
||||
const allSources = sources.ok ? ["None", "Entire System", ...sources.targets] : null;
|
||||
const hasPipewirePulse = sources.ok ? sources.hasPipewirePulse : true;
|
||||
|
||||
const [ignorePulseWarning, setIgnorePulseWarning] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -345,32 +349,38 @@ function AudioSourcePickerLinux({
|
||||
<Forms.FormTitle>Audio Source</Forms.FormTitle>
|
||||
)}
|
||||
|
||||
{!sources.ok &&
|
||||
(sources.isGlibcxxToOld ? (
|
||||
<Forms.FormText>
|
||||
Failed to retrieve Audio Sources because your C++ library is too old to run venmic. If you
|
||||
would 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>
|
||||
))}
|
||||
{!sources.ok && sources.isGlibCxxOutdated && (
|
||||
<Forms.FormText>
|
||||
Failed to retrieve Audio Sources because your C++ library is too old to run
|
||||
<a href="https://github.com/Vencord/venmic" target="_blank">
|
||||
venmic
|
||||
</a>
|
||||
. See{" "}
|
||||
<a href="https://gist.github.com/Vendicated/b655044ffbb16b2716095a448c6d827a" target="_blank">
|
||||
this guide
|
||||
</a>{" "}
|
||||
for possible solutions.
|
||||
</Forms.FormText>
|
||||
)}
|
||||
|
||||
{allSources && (
|
||||
<Select
|
||||
options={allSources.map(s => ({ label: s, value: s, default: s === "None" }))}
|
||||
isSelected={s => s === audioSource}
|
||||
select={setAudioSource}
|
||||
serialize={String}
|
||||
/>
|
||||
{hasPipewirePulse || ignorePulseWarning ? (
|
||||
allSources && (
|
||||
<Select
|
||||
options={allSources.map(s => ({ label: s, value: s, default: s === "None" }))}
|
||||
isSelected={s => s === audioSource}
|
||||
select={setAudioSource}
|
||||
serialize={String}
|
||||
/>
|
||||
)
|
||||
) : (
|
||||
<Text variant="text-sm/normal">
|
||||
Could not find pipewire-pulse. This usually means that you do not run pipewire as your main
|
||||
audio-server. <br />
|
||||
You can still continue, however, please beware that you can only share audio of apps that are
|
||||
running under pipewire.
|
||||
<br />
|
||||
<a onClick={() => setIgnorePulseWarning(true)}>I know what I'm doing</a>
|
||||
</Text>
|
||||
)}
|
||||
|
||||
<Forms.FormDivider className={Margins.top16 + " " + Margins.bottom16} />
|
||||
|
||||
24
src/renderer/patches/hideSwitchDevice.tsx
Normal file
24
src/renderer/patches/hideSwitchDevice.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: GPL-3.0
|
||||
* Vesktop, a desktop app aiming to give you a snappier Discord Experience
|
||||
* Copyright (c) 2023 Vendicated and Vencord contributors
|
||||
*/
|
||||
|
||||
import { addPatch } from "./shared";
|
||||
|
||||
addPatch({
|
||||
patches: [
|
||||
{
|
||||
find: "lastOutputSystemDevice.justChanged",
|
||||
replacement: {
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
match: /(\i)\.default\.getState\(\).neverShowModal/,
|
||||
replace: "$& || $self.shouldIgnore($1)"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
shouldIgnore(state: any) {
|
||||
return Object.keys(state?.default?.lastDeviceConnected ?? {})?.[0] === "vencord-screen-share";
|
||||
}
|
||||
});
|
||||
@@ -7,6 +7,7 @@
|
||||
// TODO: Possibly auto generate glob if we have more patches in the future
|
||||
import "./enableNotificationsByDefault";
|
||||
import "./platformClass";
|
||||
import "./hideSwitchDevice";
|
||||
import "./screenShareFixes";
|
||||
import "./spellCheck";
|
||||
import "./windowsTitleBar";
|
||||
|
||||
@@ -11,11 +11,12 @@ import { isLinux } from "renderer/utils";
|
||||
const logger = new Logger("VesktopStreamFixes");
|
||||
|
||||
if (isLinux) {
|
||||
const original = navigator.mediaDevices.getDisplayMedia;
|
||||
const originalMedia = navigator.mediaDevices.getDisplayMedia;
|
||||
const originalDevices = navigator.mediaDevices.enumerateDevices;
|
||||
|
||||
async function getVirtmic() {
|
||||
try {
|
||||
const devices = await navigator.mediaDevices.enumerateDevices();
|
||||
const devices = await originalDevices();
|
||||
const audioDevice = devices.find(({ label }) => label === "vencord-screen-share");
|
||||
return audioDevice?.deviceId;
|
||||
} catch (error) {
|
||||
@@ -23,8 +24,13 @@ if (isLinux) {
|
||||
}
|
||||
}
|
||||
|
||||
navigator.mediaDevices.enumerateDevices = async function () {
|
||||
const result = await originalDevices.call(this);
|
||||
return result.filter(x => x.label !== "vencord-screen-share");
|
||||
};
|
||||
|
||||
navigator.mediaDevices.getDisplayMedia = async function (opts) {
|
||||
const stream = await original.call(this, opts);
|
||||
const stream = await originalMedia.call(this, opts);
|
||||
const id = await getVirtmic();
|
||||
|
||||
const frameRate = Number(currentSettings?.fps);
|
||||
|
||||
Reference in New Issue
Block a user