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

Side by Side Diff: media/audio/cras/audio_manager_cras.cc

Issue 2795933002: cros: Using virtual audio device label for internal device (Closed)
Patch Set: Created 3 years, 8 months 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 | « no previous file | 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "media/audio/cras/audio_manager_cras.h" 5 #include "media/audio/cras/audio_manager_cras.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // Define bounds for the output buffer size. 42 // Define bounds for the output buffer size.
43 const int kMinimumOutputBufferSize = 512; 43 const int kMinimumOutputBufferSize = 512;
44 const int kMaximumOutputBufferSize = 8192; 44 const int kMaximumOutputBufferSize = 8192;
45 45
46 // Default input buffer size. 46 // Default input buffer size.
47 const int kDefaultInputBufferSize = 1024; 47 const int kDefaultInputBufferSize = 1024;
48 48
49 const char kBeamformingOnDeviceId[] = "default-beamforming-on"; 49 const char kBeamformingOnDeviceId[] = "default-beamforming-on";
50 const char kBeamformingOffDeviceId[] = "default-beamforming-off"; 50 const char kBeamformingOffDeviceId[] = "default-beamforming-off";
51 51
52 const char kInternalInputDevice[] = "Built-in microphone";
tommi (sloooow) - chröme 2017/04/04 10:50:08 I'd prefer names that are intentionally not like w
Qiang(Joe) Xu 2017/04/04 18:46:24 If that is the concern, sgtm. I think 'b' should b
53 const char kInternalOutputDevice[] = "Built-in speaker";
54
52 enum CrosBeamformingDeviceState { 55 enum CrosBeamformingDeviceState {
53 BEAMFORMING_DEFAULT_ENABLED = 0, 56 BEAMFORMING_DEFAULT_ENABLED = 0,
54 BEAMFORMING_USER_ENABLED, 57 BEAMFORMING_USER_ENABLED,
55 BEAMFORMING_DEFAULT_DISABLED, 58 BEAMFORMING_DEFAULT_DISABLED,
56 BEAMFORMING_USER_DISABLED, 59 BEAMFORMING_USER_DISABLED,
57 BEAMFORMING_STATE_MAX = BEAMFORMING_USER_DISABLED 60 BEAMFORMING_STATE_MAX = BEAMFORMING_USER_DISABLED
58 }; 61 };
59 62
60 void RecordBeamformingDeviceState(CrosBeamformingDeviceState state) { 63 void RecordBeamformingDeviceState(CrosBeamformingDeviceState state) {
61 UMA_HISTOGRAM_ENUMERATION("Media.CrosBeamformingDeviceState", state, 64 UMA_HISTOGRAM_ENUMERATION("Media.CrosBeamformingDeviceState", state,
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 // array. Add the virtual beamforming device to the list. When this device is 160 // array. Add the virtual beamforming device to the list. When this device is
158 // queried through GetInputStreamParameters, provide the cached mic positions. 161 // queried through GetInputStreamParameters, provide the cached mic positions.
159 if (is_input && mic_positions_.size() > 1) 162 if (is_input && mic_positions_.size() > 1)
160 AddBeamformingDevices(device_names); 163 AddBeamformingDevices(device_names);
161 else 164 else
162 device_names->push_back(AudioDeviceName::CreateDefault()); 165 device_names->push_back(AudioDeviceName::CreateDefault());
163 166
164 if (base::FeatureList::IsEnabled(features::kEnumerateAudioDevices)) { 167 if (base::FeatureList::IsEnabled(features::kEnumerateAudioDevices)) {
165 chromeos::AudioDeviceList devices; 168 chromeos::AudioDeviceList devices;
166 chromeos::CrasAudioHandler::Get()->GetAudioDevices(&devices); 169 chromeos::CrasAudioHandler::Get()->GetAudioDevices(&devices);
170
171 int internal_input_dev_index = 0;
172 int internal_output_dev_index = 0;
173 for (const auto& device : devices) {
174 if (device.type == chromeos::AUDIO_TYPE_INTERNAL_MIC)
175 internal_input_dev_index = dev_index_of(device.id);
176 else if (device.type == chromeos::AUDIO_TYPE_INTERNAL_SPEAKER)
177 internal_output_dev_index = dev_index_of(device.id);
178 }
179
180 bool has_internal_input = false;
181 bool has_internal_output = false;
167 for (const auto& device : devices) { 182 for (const auto& device : devices) {
168 if (device.is_input == is_input && device.is_for_simple_usage()) { 183 if (device.is_input == is_input && device.is_for_simple_usage()) {
169 device_names->emplace_back(device.display_name, 184 int dev_index = dev_index_of(device.id);
170 base::Uint64ToString(device.id)); 185 if (dev_index == internal_input_dev_index) {
186 if (!has_internal_input) {
187 device_names->emplace_back(kInternalInputDevice,
188 base::Uint64ToString(device.id));
189 has_internal_input = true;
190 }
191 } else if (dev_index == internal_output_dev_index) {
192 if (!has_internal_output) {
193 device_names->emplace_back(kInternalOutputDevice,
194 base::Uint64ToString(device.id));
195 has_internal_output = true;
196 }
197 } else {
198 device_names->emplace_back(device.display_name,
199 base::Uint64ToString(device.id));
200 }
171 } 201 }
172 } 202 }
173 } 203 }
174 } 204 }
175 205
176 void AudioManagerCras::GetAudioInputDeviceNames( 206 void AudioManagerCras::GetAudioInputDeviceNames(
177 AudioDeviceNames* device_names) { 207 AudioDeviceNames* device_names) {
178 mic_positions_ = ParsePointsFromString(MicPositions()); 208 mic_positions_ = ParsePointsFromString(MicPositions());
179 GetAudioDeviceNamesImpl(true, device_names); 209 GetAudioDeviceNamesImpl(true, device_names);
180 } 210 }
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 347
318 bool AudioManagerCras::IsDefault(const std::string& device_id, bool is_input) { 348 bool AudioManagerCras::IsDefault(const std::string& device_id, bool is_input) {
319 AudioDeviceNames device_names; 349 AudioDeviceNames device_names;
320 GetAudioDeviceNamesImpl(is_input, &device_names); 350 GetAudioDeviceNamesImpl(is_input, &device_names);
321 DCHECK(!device_names.empty()); 351 DCHECK(!device_names.empty());
322 const AudioDeviceName& device_name = device_names.front(); 352 const AudioDeviceName& device_name = device_names.front();
323 return device_name.unique_id == device_id; 353 return device_name.unique_id == device_id;
324 } 354 }
325 355
326 } // namespace media 356 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698