Bug 1534313 - Put the default audio output first in the list of devices. r=padenot

Differential Revision: https://phabricator.services.mozilla.com/D22986

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Alex Chronopoulos 2019-03-19 10:39:57 +00:00
Родитель 178f384554
Коммит a996b0052f
1 изменённых файлов: 11 добавлений и 1 удалений

Просмотреть файл

@ -212,6 +212,7 @@ void MediaEngineWebRTC::EnumerateSpeakerDevices(
nsTArray<RefPtr<AudioDeviceInfo>> devices;
mEnumerator->EnumerateAudioOutputDevices(devices);
DebugOnly<bool> preferredDeviceFound = false;
for (auto& device : devices) {
if (device->State() == CUBEB_DEVICE_STATE_ENABLED) {
MOZ_ASSERT(device->Type() == CUBEB_DEVICE_TYPE_OUTPUT);
@ -221,7 +222,16 @@ void MediaEngineWebRTC::EnumerateSpeakerDevices(
// deviceIDs (in JS).
uuid.Append(NS_LITERAL_STRING("_Speaker"));
nsString groupId(device->GroupID());
aDevices->AppendElement(MakeRefPtr<MediaDevice>(device, uuid, groupId));
if (device->Preferred()) {
#ifdef DEBUG
MOZ_ASSERT(!preferredDeviceFound);
preferredDeviceFound = true;
#endif
aDevices->InsertElementAt(
0, MakeRefPtr<MediaDevice>(device, uuid, groupId));
} else {
aDevices->AppendElement(MakeRefPtr<MediaDevice>(device, uuid, groupId));
}
}
}
}