| 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 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 SCOPED_UMA_HISTOGRAM_TIMER( | 141 SCOPED_UMA_HISTOGRAM_TIMER( |
| 142 "Media.AudioInputDeviceManager.OpenOnDeviceThreadTime"); | 142 "Media.AudioInputDeviceManager.OpenOnDeviceThreadTime"); |
| 143 DCHECK(IsOnDeviceThread()); | 143 DCHECK(IsOnDeviceThread()); |
| 144 | 144 |
| 145 StreamDeviceInfo out(info.device.type, info.device.name, info.device.id, 0, 0, | 145 StreamDeviceInfo out(info.device.type, info.device.name, info.device.id, 0, 0, |
| 146 0); | 146 0); |
| 147 out.session_id = session_id; | 147 out.session_id = session_id; |
| 148 | 148 |
| 149 MediaStreamDevice::AudioDeviceParameters& input_params = out.device.input; | 149 MediaStreamDevice::AudioDeviceParameters& input_params = out.device.input; |
| 150 | 150 |
| 151 // Add preferred output device information if a matching output device |
| 152 // exists. |
| 153 out.device.matched_output_device_id = |
| 154 audio_manager_->GetAssociatedOutputDeviceID(info.device.id); |
| 155 |
| 151 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 156 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 152 switches::kUseFakeDeviceForMediaStream)) { | 157 switches::kUseFakeDeviceForMediaStream)) { |
| 153 // Don't need to query the hardware information if using fake device. | 158 // Don't need to query the hardware information if using fake device. |
| 154 input_params.sample_rate = 44100; | 159 input_params.sample_rate = 44100; |
| 155 input_params.channel_layout = media::CHANNEL_LAYOUT_STEREO; | 160 input_params.channel_layout = media::CHANNEL_LAYOUT_STEREO; |
| 161 if (!out.device.matched_output_device_id.empty()) { |
| 162 out.device.matched_output.sample_rate = 44100; |
| 163 out.device.matched_output.channel_layout = media::CHANNEL_LAYOUT_STEREO; |
| 164 } |
| 156 } else { | 165 } else { |
| 157 // Get the preferred sample rate and channel configuration for the | 166 // Get the preferred sample rate and channel configuration for the |
| 158 // audio device. | 167 // audio device. |
| 159 media::AudioParameters params = | 168 media::AudioParameters params = |
| 160 audio_manager_->GetInputStreamParameters(info.device.id); | 169 audio_manager_->GetInputStreamParameters(info.device.id); |
| 161 input_params.sample_rate = params.sample_rate(); | 170 input_params.sample_rate = params.sample_rate(); |
| 162 input_params.channel_layout = params.channel_layout(); | 171 input_params.channel_layout = params.channel_layout(); |
| 163 input_params.frames_per_buffer = params.frames_per_buffer(); | 172 input_params.frames_per_buffer = params.frames_per_buffer(); |
| 164 input_params.effects = params.effects(); | 173 input_params.effects = params.effects(); |
| 165 input_params.mic_positions = params.mic_positions(); | 174 input_params.mic_positions = params.mic_positions(); |
| 166 | |
| 167 // Add preferred output device information if a matching output device | |
| 168 // exists. | |
| 169 out.device.matched_output_device_id = | |
| 170 audio_manager_->GetAssociatedOutputDeviceID(info.device.id); | |
| 171 if (!out.device.matched_output_device_id.empty()) { | 175 if (!out.device.matched_output_device_id.empty()) { |
| 172 params = audio_manager_->GetOutputStreamParameters( | 176 params = audio_manager_->GetOutputStreamParameters( |
| 173 out.device.matched_output_device_id); | 177 out.device.matched_output_device_id); |
| 174 MediaStreamDevice::AudioDeviceParameters& matched_output_params = | 178 MediaStreamDevice::AudioDeviceParameters& matched_output_params = |
| 175 out.device.matched_output; | 179 out.device.matched_output; |
| 176 matched_output_params.sample_rate = params.sample_rate(); | 180 matched_output_params.sample_rate = params.sample_rate(); |
| 177 matched_output_params.channel_layout = params.channel_layout(); | 181 matched_output_params.channel_layout = params.channel_layout(); |
| 178 matched_output_params.frames_per_buffer = params.frames_per_buffer(); | 182 matched_output_params.frames_per_buffer = params.frames_per_buffer(); |
| 179 } | 183 } |
| 180 } | 184 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 #if defined(OS_CHROMEOS) | 228 #if defined(OS_CHROMEOS) |
| 225 void AudioInputDeviceManager::SetKeyboardMicStreamActiveOnUIThread( | 229 void AudioInputDeviceManager::SetKeyboardMicStreamActiveOnUIThread( |
| 226 bool active) { | 230 bool active) { |
| 227 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 231 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 228 chromeos::CrasAudioHandler::Get()->SetKeyboardMicActive(active); | 232 chromeos::CrasAudioHandler::Get()->SetKeyboardMicActive(active); |
| 229 } | 233 } |
| 230 #endif | 234 #endif |
| 231 | 235 |
| 232 | 236 |
| 233 } // namespace content | 237 } // namespace content |
| OLD | NEW |