lotus: don't call AudioContext.setSinkId with an undefined device id
CI / Build embedded bundle (push) Successful in 56s
CI / Publish to Gitea npm registry (push) Has been skipped

audioOutputId comes from `useMediaDevices().audioOutput.selected$?.id`, which is
undefined until a device is selected. On the Tauri desktop webview the observable
emits undefined first, so setSinkId(undefined) threw "The provided value is not
of type 'AudioSinkOptions'" on every call join (repeatedly). Guard on a string
(the default device is the empty string, still valid).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Lotus CI
2026-06-30 18:39:50 -04:00
co-authored by Claude Opus 4.8
parent e2ce8f5e3a
commit a4309f3e0c
+7 -1
View File
@@ -178,7 +178,13 @@ export function useAudioContext<S extends string>(
if (
audioContext &&
"setSinkId" in audioContext &&
!controlledAudioDevices
!controlledAudioDevices &&
// Skip until a device is actually selected. audioOutputId is undefined
// before MediaDevices resolves (e.g. on the Tauri desktop webview, where
// the selected$ observable emits undefined first); setSinkId(undefined)
// throws "The provided value is not of type 'AudioSinkOptions'". The
// default device is represented by the empty string, which is still valid.
typeof audioOutputId === "string"
) {
// https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/setSinkId
// @ts-expect-error - setSinkId doesn't exist yet in types, maybe because it's not supported everywhere.