Audio HAL: fixes for issues discovered after client conversion
Several issues addressed:
-- added IDevice.supportsAudioPatches to query whether
create/removeAudioPatch is actually supported by HAL;
-- IStreamOutCallback proxy needs to be owned by IStreamOut
implementation. In order for the client to reset the reference,
added method IStreamOut.clearCallback;
-- IDevice.open{Input|Output}Stream need to return a "suggested" audio
config from HAL;
-- code for converting between system/audio.h and HIDL
data structures has been moved to
android.hardware.audio.common@2.0-util library for reuse;
-- added a workaround for the issue with QC effects HAL trying to write
into the input parameters buffer, which is r/o by Binder design.
Bug: 30222631
Change-Id: I64af24d79c12d6ac3b0f87d085a821913e29237b
Test: tried using with WIP HIDL client on N5X
diff --git a/audio/2.0/default/Conversions.cpp b/audio/2.0/default/Conversions.cpp
index 1ba16e1..e669185 100644
--- a/audio/2.0/default/Conversions.cpp
+++ b/audio/2.0/default/Conversions.cpp
@@ -29,27 +29,31 @@
char halAddress[AUDIO_DEVICE_MAX_ADDRESS_LEN];
memset(halAddress, 0, sizeof(halAddress));
uint32_t halDevice = static_cast<uint32_t>(address.device);
- if ((halDevice & AUDIO_DEVICE_OUT_ALL_A2DP) != 0
- || (halDevice & AUDIO_DEVICE_IN_BLUETOOTH_A2DP) != 0) {
+ const bool isInput = (halDevice & AUDIO_DEVICE_BIT_IN) != 0;
+ if (isInput) halDevice &= ~AUDIO_DEVICE_BIT_IN;
+ if ((!isInput && (halDevice & AUDIO_DEVICE_OUT_ALL_A2DP) != 0)
+ || (isInput && (halDevice & AUDIO_DEVICE_IN_BLUETOOTH_A2DP) != 0)) {
snprintf(halAddress, sizeof(halAddress),
"%02X:%02X:%02X:%02X:%02X:%02X",
address.address.mac[0], address.address.mac[1], address.address.mac[2],
address.address.mac[3], address.address.mac[4], address.address.mac[5]);
- } else if ((halDevice & AUDIO_DEVICE_OUT_IP) != 0 || (halDevice & AUDIO_DEVICE_IN_IP) != 0) {
+ } else if ((!isInput && (halDevice & AUDIO_DEVICE_OUT_IP) != 0)
+ || (isInput && (halDevice & AUDIO_DEVICE_IN_IP) != 0)) {
snprintf(halAddress, sizeof(halAddress),
"%d.%d.%d.%d",
address.address.ipv4[0], address.address.ipv4[1],
address.address.ipv4[2], address.address.ipv4[3]);
- } else if ((halDevice & AUDIO_DEVICE_OUT_ALL_USB) != 0
- || (halDevice & AUDIO_DEVICE_IN_ALL_USB) != 0) {
+ } else if ((!isInput && (halDevice & AUDIO_DEVICE_OUT_ALL_USB) != 0)
+ || (isInput && (halDevice & AUDIO_DEVICE_IN_ALL_USB) != 0)) {
snprintf(halAddress, sizeof(halAddress),
"card=%d;device=%d",
address.address.alsa.card, address.address.alsa.device);
- } else if ((halDevice & AUDIO_DEVICE_OUT_BUS) != 0 || (halDevice & AUDIO_DEVICE_IN_BUS) != 0) {
+ } else if ((!isInput && (halDevice & AUDIO_DEVICE_OUT_BUS) != 0)
+ || (isInput && (halDevice & AUDIO_DEVICE_IN_BUS) != 0)) {
snprintf(halAddress, sizeof(halAddress),
"%s", address.busAddress.c_str());
- } else if ((halDevice & AUDIO_DEVICE_OUT_REMOTE_SUBMIX) != 0
- || (halDevice & AUDIO_DEVICE_IN_REMOTE_SUBMIX) != 0) {
+ } else if ((!isInput && (halDevice & AUDIO_DEVICE_OUT_REMOTE_SUBMIX)) != 0
+ || (isInput && (halDevice & AUDIO_DEVICE_IN_REMOTE_SUBMIX) != 0)) {
snprintf(halAddress, sizeof(halAddress),
"%s", address.rSubmixAddress.c_str());
}