From 77da0c912f4ea373bc306a2853667948db1a25f2 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 29 Sep 2022 17:07:10 +0100 Subject: [PATCH] Match device type too Because lots of audio & video inputs have the same name --- src/media-utils.ts | 5 ++++- src/room/GroupCallView.tsx | 12 ++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/media-utils.ts b/src/media-utils.ts index d00fc72..55650eb 100644 --- a/src/media-utils.ts +++ b/src/media-utils.ts @@ -24,9 +24,12 @@ import { logger } from "matrix-js-sdk/src/logger"; */ export async function findDeviceByName( deviceName: string, + kind: MediaDeviceKind, devices: MediaDeviceInfo[] ): Promise { - const deviceInfo = devices.find((d) => d.label === deviceName); + const deviceInfo = devices.find( + (d) => d.kind === kind && d.label === deviceName + ); return deviceInfo?.deviceId; } diff --git a/src/room/GroupCallView.tsx b/src/room/GroupCallView.tsx index be436c5..b777444 100644 --- a/src/room/GroupCallView.tsx +++ b/src/room/GroupCallView.tsx @@ -105,7 +105,11 @@ export function GroupCallView({ .data as unknown as JoinCallData; if (audioInput !== null) { - const deviceId = await findDeviceByName(audioInput, devices); + const deviceId = await findDeviceByName( + audioInput, + "audioinput", + devices + ); if (!deviceId) { logger.warn("Unknown audio input: " + audioInput); } else { @@ -117,7 +121,11 @@ export function GroupCallView({ } if (videoInput !== null) { - const deviceId = await findDeviceByName(videoInput, devices); + const deviceId = await findDeviceByName( + videoInput, + "videoinput", + devices + ); if (!deviceId) { logger.warn("Unknown video input: " + videoInput); } else {