From 0d87e3e6c91b71edc93fd8e69ee6b200d65b6f83 Mon Sep 17 00:00:00 2001 From: Miriam Zimmerman Date: Sun, 9 Feb 2025 17:29:27 -0500 Subject: [PATCH] Fix "Default" mic display --- ts/calling/findBestMatchingDevice.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ts/calling/findBestMatchingDevice.ts b/ts/calling/findBestMatchingDevice.ts index 0da510bd44..0929085f17 100644 --- a/ts/calling/findBestMatchingDevice.ts +++ b/ts/calling/findBestMatchingDevice.ts @@ -28,18 +28,22 @@ export function findBestMatchingAudioDeviceIndex( return preferred.index; } + // Number of default devices at start of list to ignore. + const offset = isWindows ? 2 : 1; + const searchArr = available.slice(offset); + if (preferred.uniqueId) { - const idMatchIndex = available.findIndex( + const idMatchIndex = searchArr.findIndex( d => d.uniqueId === preferred.uniqueId ); if (idMatchIndex !== -1) { - return idMatchIndex; + return idMatchIndex + offset; } } - const nameMatchIndex = available.findIndex(d => d.name === preferred.name); + const nameMatchIndex = searchArr.findIndex(d => d.name === preferred.name); if (nameMatchIndex !== -1) { - return nameMatchIndex; + return nameMatchIndex + offset; } return available.length > 0 ? 0 : undefined;