Commit 39cd68db authored by Armando Miraglia's avatar Armando Miraglia Committed by Commit Bot

[getUserMedia] Ensure triggering onended when a default device is unplugged.

The bug crbug.com/970153 has identified an issue which is present in the
way unplugged default and communications devices are handled. In fact,
due to the way the IDs for such devices are stored, Chromium was not
notifying that such devices were unplugged.

This CL addresses the issue by making sure that the event is triggered
on both the actual device as well as the virtual default or
communications device associated to it

BUG=970153

Change-Id: I30949cb8ca6f1d904dbdf94c4002c4c86d6cafc7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1708136Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Commit-Queue: Armando Miraglia <armax@chromium.org>
Cr-Commit-Position: refs/heads/master@{#680345}
parent b781cb24
...@@ -1057,6 +1057,7 @@ void MediaDevicesManager::MaybeStopRemovedInputDevices( ...@@ -1057,6 +1057,7 @@ void MediaDevicesManager::MaybeStopRemovedInputDevices(
DCHECK(type == blink::MEDIA_DEVICE_TYPE_AUDIO_INPUT || DCHECK(type == blink::MEDIA_DEVICE_TYPE_AUDIO_INPUT ||
type == blink::MEDIA_DEVICE_TYPE_VIDEO_INPUT); type == blink::MEDIA_DEVICE_TYPE_VIDEO_INPUT);
std::vector<blink::WebMediaDeviceInfo> removed_audio_devices;
for (const auto& old_device_info : current_snapshot_[type]) { for (const auto& old_device_info : current_snapshot_[type]) {
auto it = auto it =
std::find_if(new_snapshot.begin(), new_snapshot.end(), std::find_if(new_snapshot.begin(), new_snapshot.end(),
...@@ -1066,8 +1067,31 @@ void MediaDevicesManager::MaybeStopRemovedInputDevices( ...@@ -1066,8 +1067,31 @@ void MediaDevicesManager::MaybeStopRemovedInputDevices(
// If a device was removed, notify the MediaStreamManager to stop all // If a device was removed, notify the MediaStreamManager to stop all
// streams using that device. // streams using that device.
if (it == new_snapshot.end()) if (it == new_snapshot.end()) {
stop_removed_input_device_cb_.Run(type, old_device_info); stop_removed_input_device_cb_.Run(type, old_device_info);
if (type == blink::MEDIA_DEVICE_TYPE_AUDIO_INPUT)
removed_audio_devices.push_back(old_device_info);
}
}
// "default" and "communications" audio devices that have been removed,
// require an extra notification. In fact, such audio devices have associated
// virtual audio devices in the snapshot with the special "default" or
// "communications" IDs. The code below implements an heuristic, such that to
// identify if an audio device was default, it checks whether the old
// snapshot contained an audio device with the same group ID and device ID
// matching either "default" or "communications".
for (const auto& removed_audio_device : removed_audio_devices) {
for (const auto& old_device_info : current_snapshot_[type]) {
if (removed_audio_device.group_id == old_device_info.group_id &&
(old_device_info.device_id ==
media::AudioDeviceDescription::kDefaultDeviceId ||
old_device_info.device_id ==
media::AudioDeviceDescription::kCommunicationsDeviceId)) {
stop_removed_input_device_cb_.Run(type, old_device_info);
}
}
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment