Skip to content

Commit

Permalink
policy_hal: Prevent Sound Trigger capture on USB headset
Browse files Browse the repository at this point in the history
Sound Trigger detection is not supported on USB headset, so
the capture streams should not start on USB headset. This
change prevents USB headset device selection for Sound
Trigger capture streams.

Change-Id: I238ab26a7a9d206d6b2f8e92b35be74b051b31ed
  • Loading branch information
Quinn Male committed Sep 3, 2020
1 parent 3b0e075 commit 153d450
Showing 1 changed file with 33 additions and 10 deletions.
43 changes: 33 additions & 10 deletions policy_hal/AudioPolicyManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1953,17 +1953,40 @@ status_t AudioPolicyManagerCustom::getInputForAttr(const audio_attributes_t *att
}
}

// This workaround prevents Sound Trigger capture streams from
// starting on USB headset. Sound Trigger is not supported on
// USB headset, so the capture streams should not select USB
// headset device. Temporarily remove USB headset devices from
// the available devices list while selecting device.
bool isSoundTrigger = inputSource == AUDIO_SOURCE_HOTWORD &&
mSoundTriggerSessions.indexOfKey(session) >= 0;
DeviceVector USBDevices = mAvailableInputDevices.getDevicesFromType(
AUDIO_DEVICE_IN_USB_HEADSET);

return AudioPolicyManager::getInputForAttr(attr,
input,
riid,
session,
uid,
config,
flags,
selectedDeviceId,
inputType,
portId);
if (isSoundTrigger) {
for (size_t i = 0; i < USBDevices.size(); i++) {
mAvailableInputDevices.remove(USBDevices[i]);
}
}

status_t status = AudioPolicyManager::getInputForAttr(attr,
input,
riid,
session,
uid,
config,
flags,
selectedDeviceId,
inputType,
portId);

if (isSoundTrigger) {
for (size_t i = 0; i < USBDevices.size(); i++) {
mAvailableInputDevices.add(USBDevices[i]);
}
}

return status;
}

uint32_t AudioPolicyManagerCustom::activeNonSoundTriggerInputsCountOnDevices(audio_devices_t devices) const
Expand Down

0 comments on commit 153d450

Please sign in to comment.