Skip to content

Commit

Permalink
pulse: Only filter ported input devices with no available ports
Browse files Browse the repository at this point in the history
Leave portless devices alone.

Bug: 853693, b/79580580
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: I0e505b0f87fdb2b416ca080ad104ea6710e2ec6a
Reviewed-on: https://chromium-review.googlesource.com/1104433
Reviewed-by: Max Morin <maxmorin@chromium.org>
Commit-Queue: Oskar Sundbom <ossu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568416}
  • Loading branch information
Oskar Sundbom authored and Commit Bot committed Jun 19, 2018
1 parent b04339b commit 96352eb
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions media/audio/pulse/audio_manager_pulse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,16 @@ void AudioManagerPulse::InputDevicesInfoCallback(pa_context* context,
if (info->monitor_of_sink != PA_INVALID_INDEX)
return;

// Exclude devices that don't have an available active port (i.e it's
// unplugged). Such devices won't be picked (by pulseaudio) as default device,
// and if we have no available devices we don't want to add a default device
// to enumerations either.
if (!info->active_port ||
info->active_port->available == PA_PORT_AVAILABLE_NO)
return;
// If the device has ports, but none of them are available, skip it.
if (info->n_ports > 0) {
uint32_t port = 0;
for (; port != info->n_ports; ++port) {
if (info->ports[port]->available != PA_PORT_AVAILABLE_NO)
break;
}
if (port == info->n_ports)
return;
}

manager->devices_->push_back(AudioDeviceName(info->description, info->name));
}
Expand Down

0 comments on commit 96352eb

Please sign in to comment.