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

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

Issue 2079843003: Allow AudioManagerCras enumerate audio devices from CRAS not just defaults (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit: using display_name instead of device_name Created 4 years, 5 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 | « media/audio/cras/audio_manager_cras.h ('k') | media/media.gyp » ('j') | 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 7fdf07241aa2b5d2c97aad546af36562ffe20b62..a2f0cd3c53da2275ef7e19a4468e17c596d14dee 100644
--- a/media/audio/cras/audio_manager_cras.cc
+++ b/media/audio/cras/audio_manager_cras.cc
@@ -15,6 +15,7 @@
#include "base/metrics/histogram.h"
#include "base/nix/xdg_util.h"
#include "base/stl_util.h"
+#include "base/strings/string_number_conversions.h"
#include "chromeos/audio/audio_device.h"
#include "chromeos/audio/cras_audio_handler.h"
#include "media/audio/audio_device_description.h"
@@ -65,13 +66,6 @@ bool IsBeamformingDefaultEnabled() {
"Enabled";
}
-void AddDefaultDevice(AudioDeviceNames* device_names) {
- DCHECK(device_names->empty());
-
- // Cras will route audio from a proper physical device automatically.
- device_names->push_back(AudioDeviceName::CreateDefault());
-}
-
// Returns a mic positions string if the machine has a beamforming capable
// internal mic and otherwise an empty string.
std::string MicPositions() {
@@ -155,23 +149,35 @@ void AudioManagerCras::ShowAudioInputSettings() {
NOTIMPLEMENTED();
}
-void AudioManagerCras::GetAudioInputDeviceNames(
- AudioDeviceNames* device_names) {
+void AudioManagerCras::GetAudioDeviceNamesImpl(bool is_input,
+ AudioDeviceNames* device_names) {
DCHECK(device_names->empty());
-
- mic_positions_ = ParsePointsFromString(MicPositions());
// At least two mic positions indicates we have a beamforming capable mic
// array. Add the virtual beamforming device to the list. When this device is
// queried through GetInputStreamParameters, provide the cached mic positions.
- if (mic_positions_.size() > 1)
+ if (is_input && mic_positions_.size() > 1)
AddBeamformingDevices(device_names);
else
- AddDefaultDevice(device_names);
+ device_names->push_back(media::AudioDeviceName::CreateDefault());
+ chromeos::AudioDeviceList devices;
+ chromeos::CrasAudioHandler::Get()->GetAudioDevices(&devices);
+ 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));
+ }
+ }
+}
+
+void AudioManagerCras::GetAudioInputDeviceNames(
+ AudioDeviceNames* device_names) {
+ mic_positions_ = ParsePointsFromString(MicPositions());
+ GetAudioDeviceNamesImpl(true, device_names);
}
void AudioManagerCras::GetAudioOutputDeviceNames(
AudioDeviceNames* device_names) {
- AddDefaultDevice(device_names);
+ GetAudioDeviceNamesImpl(false, device_names);
}
AudioParameters AudioManagerCras::GetInputStreamParameters(
« no previous file with comments | « media/audio/cras/audio_manager_cras.h ('k') | media/media.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698