Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Side by Side Diff: content/browser/renderer_host/media/media_stream_manager.cc

Issue 1505353007: Disable enumeration caching for output devices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/renderer_host/media/audio_renderer_host.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/media/media_stream_manager.h" 5 #include "content/browser/renderer_host/media/media_stream_manager.h"
6 6
7 #include <cctype> 7 #include <cctype>
8 #include <list> 8 #include <list>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 device_info.device.name.clear(); 185 device_info.device.name.clear();
186 } 186 }
187 187
188 bool CalledOnIOThread() { 188 bool CalledOnIOThread() {
189 // Check if this function call is on the IO thread, except for unittests where 189 // Check if this function call is on the IO thread, except for unittests where
190 // an IO thread might not have been created. 190 // an IO thread might not have been created.
191 return BrowserThread::CurrentlyOn(BrowserThread::IO) || 191 return BrowserThread::CurrentlyOn(BrowserThread::IO) ||
192 !BrowserThread::IsMessageLoopValid(BrowserThread::IO); 192 !BrowserThread::IsMessageLoopValid(BrowserThread::IO);
193 } 193 }
194 194
195 void DummyEnumerationCallback(const AudioOutputDeviceEnumeration& e) {}
196
197 } // namespace 195 } // namespace
198 196
199 197
200 // MediaStreamManager::DeviceRequest represents a request to either enumerate 198 // MediaStreamManager::DeviceRequest represents a request to either enumerate
201 // available devices or open one or more devices. 199 // available devices or open one or more devices.
202 // TODO(perkj): MediaStreamManager still needs refactoring. I propose we create 200 // TODO(perkj): MediaStreamManager still needs refactoring. I propose we create
203 // several subclasses of DeviceRequest and move some of the responsibility of 201 // several subclasses of DeviceRequest and move some of the responsibility of
204 // the MediaStreamManager to the subclasses to get rid of the way too many if 202 // the MediaStreamManager to the subclasses to get rid of the way too many if
205 // statements in MediaStreamManager. 203 // statements in MediaStreamManager.
206 class MediaStreamManager::DeviceRequest { 204 class MediaStreamManager::DeviceRequest {
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 DCHECK_CURRENTLY_ON(BrowserThread::IO); 927 DCHECK_CURRENTLY_ON(BrowserThread::IO);
930 if (monitoring_started_) 928 if (monitoring_started_)
931 return; 929 return;
932 930
933 if (!base::SystemMonitor::Get()) 931 if (!base::SystemMonitor::Get())
934 return; 932 return;
935 933
936 monitoring_started_ = true; 934 monitoring_started_ = true;
937 base::SystemMonitor::Get()->AddDevicesChangedObserver(this); 935 base::SystemMonitor::Get()->AddDevicesChangedObserver(this);
938 936
939 // Enable caching for audio output device enumerations and do an enumeration
940 // to populate the cache.
941 audio_output_device_enumerator_->SetCachePolicy(
942 AudioOutputDeviceEnumerator::CACHE_POLICY_MANUAL_INVALIDATION);
943 audio_output_device_enumerator_->Enumerate(
944 base::Bind(&DummyEnumerationCallback));
945
946 // Enumerate both the audio and video input devices to cache the device lists 937 // Enumerate both the audio and video input devices to cache the device lists
947 // and send them to media observer. 938 // and send them to media observer.
948 ++active_enumeration_ref_count_[MEDIA_DEVICE_AUDIO_CAPTURE]; 939 ++active_enumeration_ref_count_[MEDIA_DEVICE_AUDIO_CAPTURE];
949 audio_input_device_manager_->EnumerateDevices(MEDIA_DEVICE_AUDIO_CAPTURE); 940 audio_input_device_manager_->EnumerateDevices(MEDIA_DEVICE_AUDIO_CAPTURE);
950 ++active_enumeration_ref_count_[MEDIA_DEVICE_VIDEO_CAPTURE]; 941 ++active_enumeration_ref_count_[MEDIA_DEVICE_VIDEO_CAPTURE];
951 video_capture_manager_->EnumerateDevices(MEDIA_DEVICE_VIDEO_CAPTURE); 942 video_capture_manager_->EnumerateDevices(MEDIA_DEVICE_VIDEO_CAPTURE);
952 943
953 #if defined(OS_MACOSX) 944 #if defined(OS_MACOSX)
954 BrowserThread::PostTask( 945 BrowserThread::PostTask(
955 BrowserThread::UI, FROM_HERE, 946 BrowserThread::UI, FROM_HERE,
(...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after
2050 void MediaStreamManager::OnDevicesChanged( 2041 void MediaStreamManager::OnDevicesChanged(
2051 base::SystemMonitor::DeviceType device_type) { 2042 base::SystemMonitor::DeviceType device_type) {
2052 DCHECK_CURRENTLY_ON(BrowserThread::IO); 2043 DCHECK_CURRENTLY_ON(BrowserThread::IO);
2053 2044
2054 // NOTE: This method is only called in response to physical audio/video device 2045 // NOTE: This method is only called in response to physical audio/video device
2055 // changes (from the operating system). 2046 // changes (from the operating system).
2056 2047
2057 MediaStreamType stream_type; 2048 MediaStreamType stream_type;
2058 if (device_type == base::SystemMonitor::DEVTYPE_AUDIO_CAPTURE) { 2049 if (device_type == base::SystemMonitor::DEVTYPE_AUDIO_CAPTURE) {
2059 stream_type = MEDIA_DEVICE_AUDIO_CAPTURE; 2050 stream_type = MEDIA_DEVICE_AUDIO_CAPTURE;
2060 audio_output_device_enumerator_->InvalidateCache();
2061 } else if (device_type == base::SystemMonitor::DEVTYPE_VIDEO_CAPTURE) { 2051 } else if (device_type == base::SystemMonitor::DEVTYPE_VIDEO_CAPTURE) {
2062 stream_type = MEDIA_DEVICE_VIDEO_CAPTURE; 2052 stream_type = MEDIA_DEVICE_VIDEO_CAPTURE;
2063 } else { 2053 } else {
2064 return; // Uninteresting device change. 2054 return; // Uninteresting device change.
2065 } 2055 }
2066 2056
2067 // Always do enumeration even though some enumeration is in progress, because 2057 // Always do enumeration even though some enumeration is in progress, because
2068 // those enumeration commands could be sent before these devices change. 2058 // those enumeration commands could be sent before these devices change.
2069 ++active_enumeration_ref_count_[stream_type]; 2059 ++active_enumeration_ref_count_[stream_type];
2070 GetDeviceManager(stream_type)->EnumerateDevices(stream_type); 2060 GetDeviceManager(stream_type)->EnumerateDevices(stream_type);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
2164 const std::string& device_guid, 2154 const std::string& device_guid,
2165 const std::string& raw_unique_id) { 2155 const std::string& raw_unique_id) {
2166 DCHECK(security_origin.is_valid()); 2156 DCHECK(security_origin.is_valid());
2167 DCHECK(!raw_unique_id.empty()); 2157 DCHECK(!raw_unique_id.empty());
2168 std::string guid_from_raw_device_id = 2158 std::string guid_from_raw_device_id =
2169 GetHMACForMediaDeviceID(sc, security_origin, raw_unique_id); 2159 GetHMACForMediaDeviceID(sc, security_origin, raw_unique_id);
2170 return guid_from_raw_device_id == device_guid; 2160 return guid_from_raw_device_id == device_guid;
2171 } 2161 }
2172 2162
2173 } // namespace content 2163 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/media/audio_renderer_host.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698