Fix device selection persistence bug
This commit is contained in:
parent
bad065859c
commit
a3b972f6e7
4 changed files with 157 additions and 67 deletions
|
@ -3,20 +3,27 @@
|
|||
|
||||
import type { AudioDevice } from '@signalapp/ringrtc';
|
||||
|
||||
export function findBestMatchingAudioDeviceIndex({
|
||||
available,
|
||||
preferred,
|
||||
}: Readonly<{
|
||||
available: ReadonlyArray<AudioDevice>;
|
||||
preferred: undefined | AudioDevice;
|
||||
}>): undefined | number {
|
||||
export function findBestMatchingAudioDeviceIndex(
|
||||
{
|
||||
available,
|
||||
preferred,
|
||||
}: Readonly<{
|
||||
available: ReadonlyArray<AudioDevice>;
|
||||
preferred: undefined | AudioDevice;
|
||||
}>,
|
||||
isWindows: boolean
|
||||
): undefined | number {
|
||||
if (!preferred) {
|
||||
return available.length > 0 ? 0 : undefined;
|
||||
}
|
||||
|
||||
// On Linux and Mac, the default device is at index 0.
|
||||
// On Windows, there are two default devices, as presented by RingRTC:
|
||||
// * The default communications device (for voice calls, at index 0)
|
||||
// * the default device (for, e.g., media, at index 1)
|
||||
if (
|
||||
preferred.index === 0 ||
|
||||
(preferred.index === 1 && available.length >= 2)
|
||||
(isWindows && preferred.index === 1 && available.length >= 2)
|
||||
) {
|
||||
return preferred.index;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue