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,10 +398,7 @@ export class CallingClass {
|
|||
available: Array<AudioDevice>,
|
||||
preferred: AudioDevice | undefined
|
||||
): number | undefined {
|
||||
if (!preferred) {
|
||||
// No preference stored
|
||||
return undefined;
|
||||
}
|
||||
if (preferred) {
|
||||
// Match by uniqueId first, if available
|
||||
if (preferred.uniqueId) {
|
||||
const matchIndex = available.findIndex(
|
||||
|
@ -411,14 +408,13 @@ export class CallingClass {
|
|||
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; take the first device if there are any
|
||||
}
|
||||
// Nothing matches or no preference; take the first device if there are any
|
||||
return available.length > 0 ? 0 : undefined;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue