| 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..e1f5bb9d6eefe51cab9bb3284a3dab5e46712b20 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,39 @@ 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)
|
| + bool should_add_beamforming_devices = is_input && mic_positions_.size() > 1;
|
| + if (should_add_beamforming_devices)
|
| AddBeamformingDevices(device_names);
|
| - else
|
| - AddDefaultDevice(device_names);
|
| + chromeos::AudioDeviceList devices;
|
| + chromeos::CrasAudioHandler::Get()->GetAudioDevices(&devices);
|
| + for (const auto& device : devices) {
|
| + if (device.is_input == is_input && device.is_for_simple_usage()) {
|
| + media::AudioDeviceName device_name;
|
| + device_name.device_name = device.device_name;
|
| + device_name.unique_id = base::Uint64ToString(device.id);
|
| + device_names->push_back(device_name);
|
| + }
|
| + }
|
| + if (!device_names->empty() && !should_add_beamforming_devices) {
|
| + device_names->push_front(media::AudioDeviceName::CreateDefault());
|
| + }
|
| +}
|
| +
|
| +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(
|
|
|