| OLD | NEW |
| 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/audio_input_device_manager.h" | 5 #include "content/browser/renderer_host/media/audio_input_device_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
| 10 #include "content/public/common/media_stream_request.h" | 10 #include "content/public/common/media_stream_request.h" |
| 11 #include "media/audio/audio_device_name.h" | 11 #include "media/audio/audio_device_name.h" |
| 12 #include "media/audio/audio_input_ipc.h" | 12 #include "media/audio/audio_input_ipc.h" |
| 13 #include "media/audio/audio_manager_base.h" | 13 #include "media/audio/audio_manager_base.h" |
| 14 #include "media/audio/audio_parameters.h" | 14 #include "media/audio/audio_parameters.h" |
| 15 #include "media/base/channel_layout.h" | 15 #include "media/base/channel_layout.h" |
| 16 #include "media/base/scoped_histogram_timer.h" |
| 16 | 17 |
| 17 namespace content { | 18 namespace content { |
| 18 | 19 |
| 19 const int AudioInputDeviceManager::kFakeOpenSessionId = 1; | 20 const int AudioInputDeviceManager::kFakeOpenSessionId = 1; |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 // Starting id for the first capture session. | 23 // Starting id for the first capture session. |
| 23 const int kFirstSessionId = AudioInputDeviceManager::kFakeOpenSessionId + 1; | 24 const int kFirstSessionId = AudioInputDeviceManager::kFakeOpenSessionId + 1; |
| 24 } | 25 } |
| 25 | 26 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 use_fake_device_ = true; | 112 use_fake_device_ = true; |
| 112 } | 113 } |
| 113 | 114 |
| 114 bool AudioInputDeviceManager::ShouldUseFakeDevice() const { | 115 bool AudioInputDeviceManager::ShouldUseFakeDevice() const { |
| 115 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 116 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 116 return use_fake_device_; | 117 return use_fake_device_; |
| 117 } | 118 } |
| 118 | 119 |
| 119 void AudioInputDeviceManager::EnumerateOnDeviceThread( | 120 void AudioInputDeviceManager::EnumerateOnDeviceThread( |
| 120 MediaStreamType stream_type) { | 121 MediaStreamType stream_type) { |
| 122 SCOPED_UMA_HISTOGRAM_TIMER( |
| 123 "Media.AudioInputDeviceManager.EnumerateOnDeviceThreadTime"); |
| 121 DCHECK(IsOnDeviceThread()); | 124 DCHECK(IsOnDeviceThread()); |
| 122 | 125 |
| 123 media::AudioDeviceNames device_names; | 126 media::AudioDeviceNames device_names; |
| 124 | 127 |
| 125 switch (stream_type) { | 128 switch (stream_type) { |
| 126 case MEDIA_DEVICE_AUDIO_CAPTURE: | 129 case MEDIA_DEVICE_AUDIO_CAPTURE: |
| 127 // AudioManager is guaranteed to outlive MediaStreamManager in | 130 // AudioManager is guaranteed to outlive MediaStreamManager in |
| 128 // BrowserMainloop. | 131 // BrowserMainloop. |
| 129 audio_manager_->GetAudioInputDeviceNames(&device_names); | 132 audio_manager_->GetAudioInputDeviceNames(&device_names); |
| 130 break; | 133 break; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 154 // IO thread since MediaStreamManager handles the callback asynchronously. | 157 // IO thread since MediaStreamManager handles the callback asynchronously. |
| 155 BrowserThread::PostTask( | 158 BrowserThread::PostTask( |
| 156 BrowserThread::IO, | 159 BrowserThread::IO, |
| 157 FROM_HERE, | 160 FROM_HERE, |
| 158 base::Bind(&AudioInputDeviceManager::DevicesEnumeratedOnIOThread, | 161 base::Bind(&AudioInputDeviceManager::DevicesEnumeratedOnIOThread, |
| 159 this, stream_type, base::Passed(&devices))); | 162 this, stream_type, base::Passed(&devices))); |
| 160 } | 163 } |
| 161 | 164 |
| 162 void AudioInputDeviceManager::OpenOnDeviceThread( | 165 void AudioInputDeviceManager::OpenOnDeviceThread( |
| 163 int session_id, const StreamDeviceInfo& info) { | 166 int session_id, const StreamDeviceInfo& info) { |
| 167 SCOPED_UMA_HISTOGRAM_TIMER( |
| 168 "Media.AudioInputDeviceManager.OpenOnDeviceThreadTime"); |
| 164 DCHECK(IsOnDeviceThread()); | 169 DCHECK(IsOnDeviceThread()); |
| 165 | 170 |
| 166 StreamDeviceInfo out(info.device.type, info.device.name, info.device.id, | 171 StreamDeviceInfo out(info.device.type, info.device.name, info.device.id, |
| 167 0, 0, false); | 172 0, 0, false); |
| 168 out.session_id = session_id; | 173 out.session_id = session_id; |
| 169 if (use_fake_device_) { | 174 if (use_fake_device_) { |
| 170 // Don't need to query the hardware information if using fake device. | 175 // Don't need to query the hardware information if using fake device. |
| 171 out.device.sample_rate = 44100; | 176 out.device.sample_rate = 44100; |
| 172 out.device.channel_layout = media::CHANNEL_LAYOUT_STEREO; | 177 out.device.channel_layout = media::CHANNEL_LAYOUT_STEREO; |
| 173 } else { | 178 } else { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 for (StreamDeviceList::iterator i(devices_.begin()); i != devices_.end(); | 228 for (StreamDeviceList::iterator i(devices_.begin()); i != devices_.end(); |
| 224 ++i) { | 229 ++i) { |
| 225 if (i->session_id == session_id) | 230 if (i->session_id == session_id) |
| 226 return i; | 231 return i; |
| 227 } | 232 } |
| 228 | 233 |
| 229 return devices_.end(); | 234 return devices_.end(); |
| 230 } | 235 } |
| 231 | 236 |
| 232 } // namespace content | 237 } // namespace content |
| OLD | NEW |