Prefer audio device 0 if no device preference has been saved
This commit is contained in:
parent
04b7a29229
commit
a4c6003f34
1 changed files with 15 additions and 19 deletions
|
@ -398,27 +398,23 @@ export class CallingClass {
|
||||||
available: Array<AudioDevice>,
|
available: Array<AudioDevice>,
|
||||||
preferred: AudioDevice | undefined
|
preferred: AudioDevice | undefined
|
||||||
): number | undefined {
|
): number | undefined {
|
||||||
if (!preferred) {
|
if (preferred) {
|
||||||
// No preference stored
|
// Match by uniqueId first, if available
|
||||||
return undefined;
|
if (preferred.uniqueId) {
|
||||||
}
|
const matchIndex = available.findIndex(
|
||||||
// Match by uniqueId first, if available
|
d => d.uniqueId === preferred.uniqueId
|
||||||
if (preferred.uniqueId) {
|
);
|
||||||
const matchIndex = available.findIndex(
|
if (matchIndex !== -1) {
|
||||||
d => d.uniqueId === preferred.uniqueId
|
return matchIndex;
|
||||||
);
|
}
|
||||||
if (matchIndex !== -1) {
|
}
|
||||||
return matchIndex;
|
// Match by name second
|
||||||
|
const matchingNames = available.filter(d => d.name === preferred.name);
|
||||||
|
if (matchingNames.length > 0) {
|
||||||
|
return matchingNames[0].index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Nothing matches or no preference; take the first device if there are any
|
||||||
// Match by name second
|
|
||||||
const matchingNames = available.filter(d => d.name === preferred.name);
|
|
||||||
if (matchingNames.length > 0) {
|
|
||||||
return matchingNames[0].index;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Nothing matches; take the first device if there are any
|
|
||||||
return available.length > 0 ? 0 : undefined;
|
return available.length > 0 ? 0 : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue