diff options
author | Luna <imlvnaa@gmail.com> | 2023-09-06 17:10:33 +0000 |
---|---|---|
committer | Ven <ven@noreply.codeberg.org> | 2023-09-06 17:10:33 +0000 |
commit | 452bf72e5675f52bc52694d7191074fe28216a45 (patch) | |
tree | a6dcc14212b4b6bf0ef4f16654dabcd7329a3924 /src/plugins/rnnoise.web | |
parent | afa47addd7e72ac5b22d9801b166e20601847433 (diff) | |
download | Vencord-452bf72e5675f52bc52694d7191074fe28216a45.tar.gz Vencord-452bf72e5675f52bc52694d7191074fe28216a45.tar.bz2 Vencord-452bf72e5675f52bc52694d7191074fe28216a45.zip |
rnnoise: fix error on webcam (#29)
errored because there was no audio stream, luckily the patched function had a boolean indicating if it was audio or not so just ignore it if it isnt
Reviewed-on: https://codeberg.org/Ven/cord/pulls/29
Co-authored-by: Luna <imlvnaa@gmail.com>
Co-committed-by: Luna <imlvnaa@gmail.com>
Diffstat (limited to 'src/plugins/rnnoise.web')
-rw-r--r-- | src/plugins/rnnoise.web/index.tsx | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/plugins/rnnoise.web/index.tsx b/src/plugins/rnnoise.web/index.tsx index 7117ca2..8de6557 100644 --- a/src/plugins/rnnoise.web/index.tsx +++ b/src/plugins/rnnoise.web/index.tsx @@ -145,7 +145,7 @@ export default definePlugin({ find: "window.webkitAudioContext", replacement: { match: /(?<=\i\.acquire=function\((\i)\)\{return )navigator\.mediaDevices\.getUserMedia\(\1\)(?=\})/, - replace: m => `${m}.then(stream => $self.connectRnnoise(stream))` + replace: "$&.then(stream => $self.connectRnnoise(stream, $1.audio))" }, }, { @@ -182,7 +182,8 @@ export default definePlugin({ setEnabled, isEnabled: () => settings.store.isEnabled, - async connectRnnoise(stream: MediaStream): Promise<MediaStream> { + async connectRnnoise(stream: MediaStream, isAudio: boolean): Promise<MediaStream> { + if (!isAudio) return stream; if (!settings.store.isEnabled) return stream; const audioCtx = new AudioContext(); |