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

Unified Diff: media/audio/cras/audio_manager_cras.cc

Issue 2795933002: cros: Using virtual audio device label for internal device (Closed)
Patch Set: Built-in-mic and Built-in-speaker 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/cras/audio_manager_cras.cc
diff --git a/media/audio/cras/audio_manager_cras.cc b/media/audio/cras/audio_manager_cras.cc
index 65a2f66d43d228d2856ca1242c3e62bd46d94889..85ff96e4ccc11b14a6185ab8d51f1064987b5ee6 100644
--- a/media/audio/cras/audio_manager_cras.cc
+++ b/media/audio/cras/audio_manager_cras.cc
@@ -49,6 +49,9 @@ const int kDefaultInputBufferSize = 1024;
const char kBeamformingOnDeviceId[] = "default-beamforming-on";
const char kBeamformingOffDeviceId[] = "default-beamforming-off";
+const char kInternalInputDevice[] = "Built-in-mic";
+const char kInternalOutputDevice[] = "Built-in-speaker";
+
enum CrosBeamformingDeviceState {
BEAMFORMING_DEFAULT_ENABLED = 0,
BEAMFORMING_USER_ENABLED,
@@ -164,10 +167,37 @@ void AudioManagerCras::GetAudioDeviceNamesImpl(bool is_input,
if (base::FeatureList::IsEnabled(features::kEnumerateAudioDevices)) {
chromeos::AudioDeviceList devices;
chromeos::CrasAudioHandler::Get()->GetAudioDevices(&devices);
+
+ int internal_input_dev_index = 0;
+ int internal_output_dev_index = 0;
+ for (const auto& device : devices) {
+ if (device.type == chromeos::AUDIO_TYPE_INTERNAL_MIC)
+ internal_input_dev_index = dev_index_of(device.id);
+ else if (device.type == chromeos::AUDIO_TYPE_INTERNAL_SPEAKER)
+ internal_output_dev_index = dev_index_of(device.id);
+ }
+
+ bool has_internal_input = false;
+ bool has_internal_output = false;
for (const auto& device : devices) {
if (device.is_input == is_input && device.is_for_simple_usage()) {
- device_names->emplace_back(device.display_name,
- base::Uint64ToString(device.id));
+ int dev_index = dev_index_of(device.id);
+ if (dev_index == internal_input_dev_index) {
+ if (!has_internal_input) {
+ device_names->emplace_back(kInternalInputDevice,
+ base::Uint64ToString(device.id));
+ has_internal_input = true;
+ }
+ } else if (dev_index == internal_output_dev_index) {
+ if (!has_internal_output) {
+ device_names->emplace_back(kInternalOutputDevice,
+ base::Uint64ToString(device.id));
+ has_internal_output = true;
+ }
+ } else {
+ device_names->emplace_back(device.display_name,
+ base::Uint64ToString(device.id));
+ }
}
}
}
« 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