From f5d144f7ca773750ea7be371f14f9fc975a15862 Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Thu, 26 Mar 2015 19:00:00 -0700 Subject: audio policy: fix IOProfile::isCompatibleProfile() Handle composite devices in IOProfile::isCompatibleProfile() by just checking the type in this case, not the address which is relevant only if a single device type is passed as input. Also remove warning. Bug: 19762960. Change-Id: Iaecb7fcfbf7ad39b1e33cb460922f7c069a34a00 --- services/audiopolicy/managerdefault/Devices.cpp | 2 +- services/audiopolicy/managerdefault/IOProfile.cpp | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'services/audiopolicy') diff --git a/services/audiopolicy/managerdefault/Devices.cpp b/services/audiopolicy/managerdefault/Devices.cpp index 13c8bbc..5f5ac15 100644 --- a/services/audiopolicy/managerdefault/Devices.cpp +++ b/services/audiopolicy/managerdefault/Devices.cpp @@ -237,7 +237,7 @@ void DeviceDescriptor::toAudioPortConfig(struct audio_port_config *dstConfig, // without the test? // This has been demonstrated to NOT be true (at start up) // ALOG_ASSERT(mModule != NULL); - dstConfig->ext.device.hw_module = mModule != NULL ? mModule->mHandle : NULL; + dstConfig->ext.device.hw_module = mModule != 0 ? mModule->mHandle : AUDIO_IO_HANDLE_NONE; strncpy(dstConfig->ext.device.address, mAddress.string(), AUDIO_DEVICE_MAX_ADDRESS_LEN); } diff --git a/services/audiopolicy/managerdefault/IOProfile.cpp b/services/audiopolicy/managerdefault/IOProfile.cpp index 538ac1a..8000914 100644 --- a/services/audiopolicy/managerdefault/IOProfile.cpp +++ b/services/audiopolicy/managerdefault/IOProfile.cpp @@ -46,8 +46,16 @@ bool IOProfile::isCompatibleProfile(audio_devices_t device, const bool isRecordThread = mType == AUDIO_PORT_TYPE_MIX && mRole == AUDIO_PORT_ROLE_SINK; ALOG_ASSERT(isPlaybackThread != isRecordThread); - if (device != AUDIO_DEVICE_NONE && mSupportedDevices.getDevice(device, address) == 0) { - return false; + + if (device != AUDIO_DEVICE_NONE) { + // just check types if multiple devices are selected + if (popcount(device & ~AUDIO_DEVICE_BIT_IN) > 1) { + if ((mSupportedDevices.types() & device) != device) { + return false; + } + } else if (mSupportedDevices.getDevice(device, address) == 0) { + return false; + } } if (samplingRate == 0) { -- cgit v1.1