Commit 0fe699a8 authored by Guido Urdaneta's avatar Guido Urdaneta Committed by Commit Bot

Stop streams associated to removed devices in MediaDevicesManager.

This fixes a bug where removing a device did not result in stopping all
its associated streams.

A unit test for this requires a minor refactoring to remove the
MediaStreamManager dependency from MediaDevicesManager, and will be
provided in a follow-up CL. This CL is deliberately simple in order to
make merging easier.

Bug: 856658
Change-Id: I84ef2856195cc7650bb08992d2095f8f853e9ea9
Reviewed-on: https://chromium-review.googlesource.com/1124323Reviewed-by: default avatarHenrik Boström <hbos@chromium.org>
Commit-Queue: Guido Urdaneta <guidou@chromium.org>
Cr-Commit-Position: refs/heads/master@{#572176}
parent c8e2b4d4
...@@ -804,6 +804,12 @@ void MediaDevicesManager::UpdateSnapshot( ...@@ -804,6 +804,12 @@ void MediaDevicesManager::UpdateSnapshot(
bool need_update_device_change_subscribers = false; bool need_update_device_change_subscribers = false;
MediaDeviceInfoArray& old_snapshot = current_snapshot_[type]; MediaDeviceInfoArray& old_snapshot = current_snapshot_[type];
if (old_snapshot.size() != new_snapshot.size() &&
(type == MEDIA_DEVICE_TYPE_AUDIO_INPUT ||
type == MEDIA_DEVICE_TYPE_VIDEO_INPUT)) {
StopRemovedDevices(type, new_snapshot);
}
// Update the cached snapshot and send notifications only if the device list // Update the cached snapshot and send notifications only if the device list
// has changed. // has changed.
if (old_snapshot.size() != new_snapshot.size() || if (old_snapshot.size() != new_snapshot.size() ||
...@@ -893,7 +899,7 @@ void MediaDevicesManager::HandleDevicesChanged(MediaDeviceType type) { ...@@ -893,7 +899,7 @@ void MediaDevicesManager::HandleDevicesChanged(MediaDeviceType type) {
DoEnumerateDevices(type); DoEnumerateDevices(type);
} }
void MediaDevicesManager::NotifyMediaStreamManager( void MediaDevicesManager::StopRemovedDevices(
MediaDeviceType type, MediaDeviceType type,
const MediaDeviceInfoArray& new_snapshot) { const MediaDeviceInfoArray& new_snapshot) {
DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK_CURRENTLY_ON(BrowserThread::IO);
...@@ -914,6 +920,17 @@ void MediaDevicesManager::NotifyMediaStreamManager( ...@@ -914,6 +920,17 @@ void MediaDevicesManager::NotifyMediaStreamManager(
if (it == new_snapshot.end()) if (it == new_snapshot.end())
media_stream_manager_->StopRemovedDevice(type, old_device_info); media_stream_manager_->StopRemovedDevice(type, old_device_info);
} }
}
void MediaDevicesManager::NotifyMediaStreamManager(
MediaDeviceType type,
const MediaDeviceInfoArray& new_snapshot) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(type == MEDIA_DEVICE_TYPE_AUDIO_INPUT ||
type == MEDIA_DEVICE_TYPE_VIDEO_INPUT);
if (!media_stream_manager_)
return;
media_stream_manager_->NotifyDevicesChanged(type, new_snapshot); media_stream_manager_->NotifyDevicesChanged(type, new_snapshot);
} }
......
...@@ -223,6 +223,8 @@ class CONTENT_EXPORT MediaDevicesManager ...@@ -223,6 +223,8 @@ class CONTENT_EXPORT MediaDevicesManager
// Helpers to handle device-change notification. // Helpers to handle device-change notification.
void HandleDevicesChanged(MediaDeviceType type); void HandleDevicesChanged(MediaDeviceType type);
void StopRemovedDevices(MediaDeviceType type,
const MediaDeviceInfoArray& new_snapshot);
void NotifyMediaStreamManager(MediaDeviceType type, void NotifyMediaStreamManager(MediaDeviceType type,
const MediaDeviceInfoArray& new_snapshot); const MediaDeviceInfoArray& new_snapshot);
void NotifyDeviceChangeSubscribers(MediaDeviceType type, void NotifyDeviceChangeSubscribers(MediaDeviceType type,
......
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