Chromium Code Reviews| 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 <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 } | 69 } |
| 70 | 70 |
| 71 int AudioInputDeviceManager::Open(const MediaStreamDevice& device) { | 71 int AudioInputDeviceManager::Open(const MediaStreamDevice& device) { |
| 72 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 72 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 73 // Generate a new id for this device. | 73 // Generate a new id for this device. |
| 74 int session_id = next_capture_session_id_++; | 74 int session_id = next_capture_session_id_++; |
| 75 | 75 |
| 76 // base::Unretained(this) is safe, because AudioInputDeviceManager is | 76 // base::Unretained(this) is safe, because AudioInputDeviceManager is |
| 77 // destroyed not earlier than on the IO message loop destruction. | 77 // destroyed not earlier than on the IO message loop destruction. |
| 78 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 78 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 79 switches::kUseFakeDeviceForMediaStream)) { | 79 switches::kUseFakeDeviceForMediaStream)) { |
|
o1ka
2017/06/22 09:32:34
Alternatively we may check here if device.type is
| |
| 80 audio_system_->GetAssociatedOutputDeviceID( | 80 audio_system_->GetAssociatedOutputDeviceID( |
| 81 device.id, | 81 device.id, |
| 82 base::BindOnce(&AudioInputDeviceManager::OpenedOnIOThread, | 82 base::BindOnce(&AudioInputDeviceManager::OpenedOnIOThread, |
| 83 base::Unretained(this), session_id, device, | 83 base::Unretained(this), session_id, device, |
| 84 base::TimeTicks::Now(), | 84 base::TimeTicks::Now(), |
| 85 media::AudioParameters::UnavailableDeviceParams(), | 85 media::AudioParameters::UnavailableDeviceParams(), |
| 86 media::AudioParameters::UnavailableDeviceParams())); | 86 media::AudioParameters::UnavailableDeviceParams())); |
| 87 } else { | 87 } else { |
| 88 // TODO(tommi): As is, we hit this code path when device.type is | 88 // TODO(tommi): As is, we hit this code path when device.type is |
| 89 // MEDIA_TAB_AUDIO_CAPTURE and the device id is not a device that | 89 // MEDIA_TAB_AUDIO_CAPTURE and the device id is not a device that |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 161 base::TimeTicks start_time, | 161 base::TimeTicks start_time, |
| 162 const media::AudioParameters& input_params, | 162 const media::AudioParameters& input_params, |
| 163 const media::AudioParameters& matched_output_params, | 163 const media::AudioParameters& matched_output_params, |
| 164 const std::string& matched_output_device_id) { | 164 const std::string& matched_output_device_id) { |
| 165 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 165 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 166 DCHECK(GetDevice(session_id) == devices_.end()); | 166 DCHECK(GetDevice(session_id) == devices_.end()); |
| 167 | 167 |
| 168 UMA_HISTOGRAM_TIMES("Media.AudioInputDeviceManager.OpenOnDeviceThreadTime", | 168 UMA_HISTOGRAM_TIMES("Media.AudioInputDeviceManager.OpenOnDeviceThreadTime", |
| 169 base::TimeTicks::Now() - start_time); | 169 base::TimeTicks::Now() - start_time); |
| 170 | 170 |
| 171 media::AudioParameters valid_input_params( | |
|
Guido Urdaneta
2017/06/22 09:37:16
nit: Use assignment syntax instead.
| |
| 172 input_params.IsValid() | |
| 173 ? input_params | |
| 174 : media::AudioParameters::UnavailableDeviceParams()); | |
| 175 | |
| 171 StreamDeviceInfo info(device.type, device.name, device.id); | 176 StreamDeviceInfo info(device.type, device.name, device.id); |
| 172 info.session_id = session_id; | 177 info.session_id = session_id; |
| 173 info.device.input.sample_rate = input_params.sample_rate(); | 178 info.device.input.sample_rate = valid_input_params.sample_rate(); |
| 174 info.device.input.channel_layout = input_params.channel_layout(); | 179 info.device.input.channel_layout = valid_input_params.channel_layout(); |
| 175 info.device.input.frames_per_buffer = input_params.frames_per_buffer(); | 180 info.device.input.frames_per_buffer = valid_input_params.frames_per_buffer(); |
| 176 info.device.input.effects = input_params.effects(); | 181 info.device.input.effects = valid_input_params.effects(); |
| 177 info.device.input.mic_positions = input_params.mic_positions(); | 182 info.device.input.mic_positions = valid_input_params.mic_positions(); |
| 178 info.device.matched_output_device_id = matched_output_device_id; | 183 info.device.matched_output_device_id = matched_output_device_id; |
| 179 info.device.matched_output.sample_rate = matched_output_params.sample_rate(); | 184 info.device.matched_output.sample_rate = matched_output_params.sample_rate(); |
| 180 info.device.matched_output.channel_layout = | 185 info.device.matched_output.channel_layout = |
| 181 matched_output_params.channel_layout(); | 186 matched_output_params.channel_layout(); |
| 182 info.device.matched_output.frames_per_buffer = | 187 info.device.matched_output.frames_per_buffer = |
| 183 matched_output_params.frames_per_buffer(); | 188 matched_output_params.frames_per_buffer(); |
| 184 info.device.matched_output.effects = matched_output_params.effects(); | 189 info.device.matched_output.effects = matched_output_params.effects(); |
| 185 | 190 |
| 186 devices_.push_back(info); | 191 devices_.push_back(info); |
| 187 | 192 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 210 | 215 |
| 211 #if defined(OS_CHROMEOS) | 216 #if defined(OS_CHROMEOS) |
| 212 void AudioInputDeviceManager::SetKeyboardMicStreamActiveOnUIThread( | 217 void AudioInputDeviceManager::SetKeyboardMicStreamActiveOnUIThread( |
| 213 bool active) { | 218 bool active) { |
| 214 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 219 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 215 chromeos::CrasAudioHandler::Get()->SetKeyboardMicActive(active); | 220 chromeos::CrasAudioHandler::Get()->SetKeyboardMicActive(active); |
| 216 } | 221 } |
| 217 #endif | 222 #endif |
| 218 | 223 |
| 219 } // namespace content | 224 } // namespace content |
| OLD | NEW |