mirror of
https://github.com/vector-im/element-call.git
synced 2026-08-29 21:15:19 +00:00
disable audio output beeing anything else then undefined
Signed-off-by: Timo K <toger5@hotmail.de>
This commit is contained in:
@@ -65,7 +65,8 @@ function useObservableState<T>(
|
|||||||
function useMediaDevice(
|
function useMediaDevice(
|
||||||
kind: MediaDeviceKind,
|
kind: MediaDeviceKind,
|
||||||
fallbackDevice: string | undefined,
|
fallbackDevice: string | undefined,
|
||||||
usingNames: boolean
|
usingNames: boolean,
|
||||||
|
alwaysDefault: boolean = false
|
||||||
): MediaDevice {
|
): MediaDevice {
|
||||||
// Make sure we don't needlessly reset to a device observer without names,
|
// Make sure we don't needlessly reset to a device observer without names,
|
||||||
// once permissions are already given
|
// once permissions are already given
|
||||||
@@ -86,18 +87,19 @@ function useMediaDevice(
|
|||||||
const available = useObservableState(deviceObserver, []);
|
const available = useObservableState(deviceObserver, []);
|
||||||
const [selectedId, select] = useState(fallbackDevice);
|
const [selectedId, select] = useState(fallbackDevice);
|
||||||
|
|
||||||
return useMemo(
|
return useMemo(() => {
|
||||||
() => ({
|
const devId = available.some((d) => d.deviceId === selectedId)
|
||||||
|
? selectedId
|
||||||
|
: available.some((d) => d.deviceId === fallbackDevice)
|
||||||
|
? fallbackDevice
|
||||||
|
: available.at(0)?.deviceId;
|
||||||
|
|
||||||
|
return {
|
||||||
available,
|
available,
|
||||||
selectedId: available.some((d) => d.deviceId === selectedId)
|
selectedId: alwaysDefault ? undefined : devId,
|
||||||
? selectedId
|
|
||||||
: available.some((d) => d.deviceId === fallbackDevice)
|
|
||||||
? fallbackDevice
|
|
||||||
: available.at(0)?.deviceId,
|
|
||||||
select,
|
select,
|
||||||
}),
|
};
|
||||||
[available, selectedId, fallbackDevice, select]
|
}, [available, selectedId, fallbackDevice, select, alwaysDefault]);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const deviceStub: MediaDevice = {
|
const deviceStub: MediaDevice = {
|
||||||
@@ -136,7 +138,8 @@ export const MediaDevicesProvider: FC<Props> = ({ children }) => {
|
|||||||
const audioOutput = useMediaDevice(
|
const audioOutput = useMediaDevice(
|
||||||
"audiooutput",
|
"audiooutput",
|
||||||
audioOutputSetting,
|
audioOutputSetting,
|
||||||
usingNames
|
false,
|
||||||
|
true
|
||||||
);
|
);
|
||||||
const videoInput = useMediaDevice(
|
const videoInput = useMediaDevice(
|
||||||
"videoinput",
|
"videoinput",
|
||||||
@@ -149,10 +152,10 @@ export const MediaDevicesProvider: FC<Props> = ({ children }) => {
|
|||||||
setAudioInputSetting(audioInput.selectedId);
|
setAudioInputSetting(audioInput.selectedId);
|
||||||
}, [setAudioInputSetting, audioInput.selectedId]);
|
}, [setAudioInputSetting, audioInput.selectedId]);
|
||||||
|
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
if (audioOutput.selectedId !== undefined)
|
// if (audioOutput.selectedId !== undefined)
|
||||||
setAudioOutputSetting(audioOutput.selectedId);
|
// setAudioOutputSetting(audioOutput.selectedId);
|
||||||
}, [setAudioOutputSetting, audioOutput.selectedId]);
|
// }, [setAudioOutputSetting, audioOutput.selectedId]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (videoInput.selectedId !== undefined)
|
if (videoInput.selectedId !== undefined)
|
||||||
|
|||||||
Reference in New Issue
Block a user