Commit fa0c0b5b authored by Guido Urdaneta's avatar Guido Urdaneta Committed by Commit Bot

Let Pulse Audio select input device to use as default in AudioManagerPulse

The default input device reported by Pulse Audio is not really
a default device, but a fallback device.
Actual expected default behavior in Pulse Audio is achieved by
not specifying a device to use and letting Pulse Audio select it.
In this case Pulse first tries to use the device specified by the
PULSE_SOURCE environment variable and, if that fails, tries to use
the fallback device.

There is no API to fetch what device Pulse will actually use by default.
A consequence of this is that the groupId reported by the default
input device will not correspond to the group ID of the actual device
that will be used. This is not ideal, but it is better than the
alternative.

The groupId constrainable property still works fine with nondefault
devices.

Bug: 890010
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: I3473df314f0a36f56094c4986bf8fc9b38265fad
Reviewed-on: https://chromium-review.googlesource.com/c/1256832Reviewed-by: default avatarMax Morin <maxmorin@chromium.org>
Commit-Queue: Guido Urdaneta <guidou@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596170}
parent 9edc20f8
......@@ -160,12 +160,11 @@ AudioInputStream* AudioManagerPulse::MakeLowLatencyInputStream(
}
std::string AudioManagerPulse::GetDefaultInputDeviceID() {
#if defined(OS_CHROMEOS)
// Do not use the real default input device since it is a fallback
// device rather than a default device. Using the default input device
// reported by Pulse Audio prevents, for example, input redirection
// using the PULSE_SOURCE environment variable.
return AudioManagerBase::GetDefaultInputDeviceID();
#else
return pulse::GetRealDefaultDeviceId(input_mainloop_, input_context_,
pulse::RequestType::INPUT);
#endif
}
std::string AudioManagerPulse::GetDefaultOutputDeviceID() {
......@@ -184,15 +183,13 @@ std::string AudioManagerPulse::GetAssociatedOutputDeviceID(
DCHECK(AudioManager::Get()->GetTaskRunner()->BelongsToCurrentThread());
DCHECK(input_mainloop_);
DCHECK(input_context_);
std::string input =
(input_device_id == AudioDeviceDescription::kDefaultDeviceId)
? pulse::GetRealDefaultDeviceId(input_mainloop_, input_context_,
pulse::RequestType::INPUT)
: input_device_id;
if (input_device_id == AudioDeviceDescription::kDefaultDeviceId)
return std::string();
std::string input_bus =
pulse::GetBusOfInput(input_mainloop_, input_context_, input);
return input_bus.empty() ? ""
pulse::GetBusOfInput(input_mainloop_, input_context_, input_device_id);
return input_bus.empty() ? std::string()
: pulse::GetOutputCorrespondingTo(
input_mainloop_, input_context_, input_bus);
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment