Bug 1614657 - Update the device list unconditionally on every gUM request. r=jib

In `MediaManager::DeviceListChanged()` we check if a device is removed in order to stop it. That eventually will send the end track event. For doing that correctly the `mDeviceIDs` must be up to date. The `mDeviceIDs` is set as a part of gUM execution in `MediaManager::EnumerateDevicesImpl` inside an if-check. However, having the if-check is not necessary anymore. First, because the device ids do not contain anymore the "default:" prefix and second because there is no real reason to differentiate real from fake devices. In addition to that the if check had an error and did not update the `mDeviceIDs` correctly on video-only or audio-only gUM requests.

Depends on D63100

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Alex Chronopoulos 2020-02-19 09:42:47 +00:00
Родитель bd69c0127b
Коммит f480a9206a
1 изменённых файлов: 8 добавлений и 20 удалений

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

@ -2168,12 +2168,9 @@ void MediaManager::DeviceListChanged() {
}
nsTArray<nsString> deviceIDs;
for (auto& device : *devices) {
nsString id;
device->GetId(id);
id.ReplaceSubstring(NS_LITERAL_STRING("default: "),
NS_LITERAL_STRING(""));
if (!deviceIDs.Contains(id)) {
deviceIDs.AppendElement(id);
}
@ -3071,8 +3068,7 @@ RefPtr<MediaManager::MgrPromise> MediaManager::EnumerateDevicesImpl(
})
->Then(
GetMainThreadSerialEventTarget(), __func__,
[aWindowId, originKey, aVideoInputEnumType, aAudioInputEnumType,
aVideoInputType, aAudioInputType, aOutDevices](bool) {
[aWindowId, originKey, aOutDevices](bool) {
// Only run if window is still on our active list.
MediaManager* mgr = MediaManager::GetIfExists();
if (!mgr || !mgr->IsWindowStillActive(aWindowId)) {
@ -3081,23 +3077,15 @@ RefPtr<MediaManager::MgrPromise> MediaManager::EnumerateDevicesImpl(
__func__);
}
// If we fetched any real cameras or mics, remove the
// "default" part of their IDs.
if (aVideoInputType == MediaSourceEnum::Camera &&
aAudioInputType == MediaSourceEnum::Microphone &&
(aVideoInputEnumType != DeviceEnumerationType::Fake ||
aAudioInputEnumType != DeviceEnumerationType::Fake)) {
mgr->mDeviceIDs.Clear();
for (auto& device : *aOutDevices) {
nsString id;
device->GetId(id);
id.ReplaceSubstring(NS_LITERAL_STRING("default: "),
NS_LITERAL_STRING(""));
if (!mgr->mDeviceIDs.Contains(id)) {
mgr->mDeviceIDs.AppendElement(id);
}
mgr->mDeviceIDs.Clear();
for (auto& device : *aOutDevices) {
nsString id;
device->GetId(id);
if (!mgr->mDeviceIDs.Contains(id)) {
mgr->mDeviceIDs.AppendElement(id);
}
}
if (!mgr->IsWindowStillActive(aWindowId)) {
return MgrPromise::CreateAndReject(
MakeRefPtr<MediaMgrError>(MediaMgrError::Name::AbortError),