polish(web): clear device lists on permission revoke; document probe-constraint omission

This commit is contained in:
Jannis Braun
2026-05-03 02:09:13 +02:00
parent 4044e910c3
commit 19d42445b0
2 changed files with 9 additions and 1 deletions
+5 -1
View File
@@ -139,7 +139,11 @@ export function useAudioDevices(): UseAudioDevicesResult {
// Enumerate when permission grants; refresh on devicechange. // Enumerate when permission grants; refresh on devicechange.
useEffect(() => { useEffect(() => {
if (permState !== 'granted') return; if (permState !== 'granted') {
setInputs([]);
setOutputs([]);
return;
}
enumerate(); enumerate();
const onChange = () => { enumerate(); }; const onChange = () => { enumerate(); };
navigator.mediaDevices.addEventListener('devicechange', onChange); navigator.mediaDevices.addEventListener('devicechange', onChange);
+4
View File
@@ -436,6 +436,10 @@ export function useLiveKit() {
let copy = 'Microphone could not be restored'; let copy = 'Microphone could not be restored';
try { try {
// Probe is intentionally constraint-free — we want to know whether the
// device is reachable, not whether full voice constraints succeed. Adding
// constraints here would create probe-vs-acquire skew (probe might fail
// for a constraint that AudioManager would have negotiated around).
const probe = await navigator.mediaDevices.getUserMedia({ const probe = await navigator.mediaDevices.getUserMedia({
audio: deviceId === 'default' ? true : { deviceId: { exact: deviceId } }, audio: deviceId === 'default' ? true : { deviceId: { exact: deviceId } },
}); });