Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f7f85438 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi
Browse files

AudioPolicy: tighter match for device descriptor query

When querying a module for a device descriptor, the matching was
  too "loose": if a device type and address was not found, a
  match was returned for just the device. While this works for device
  types where only one is connected to the system (e.g. wired headphones),
  this is an improper behavior for devices such as REMOTE_SUBMIX where
  multiple are "connected" to the DUT, but with different addresses.

Bug 27337358
Bug 27336527

Change-Id: I9b6464485da2bedde2d14b624133e02b5a3fa357
parent 7e258e85
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -50,15 +50,11 @@ bool DeviceDescriptor::equals(const sp<DeviceDescriptor>& other) const
{
    // Devices are considered equal if they:
    // - are of the same type (a device type cannot be AUDIO_DEVICE_NONE)
    // - have the same address or one device does not specify the address
    // - have the same channel mask or one device does not specify the channel mask
    // - have the same address
    if (other == 0) {
        return false;
    }
    return (mDeviceType == other->mDeviceType) &&
           (mAddress == "" || other->mAddress == "" || mAddress == other->mAddress) &&
           (mChannelMask == 0 || other->mChannelMask == 0 ||
                mChannelMask == other->mChannelMask);
    return (mDeviceType == other->mDeviceType) && (mAddress == other->mAddress);
}

void DeviceVector::refreshTypes()
+0 −6
Original line number Diff line number Diff line
@@ -310,12 +310,6 @@ sp<DeviceDescriptor> HwModuleCollection::getDeviceDescriptor(const audio_device
        if (!deviceList.isEmpty()) {
            return deviceList.itemAt(0);
        }
        deviceList = hwModule->getDeclaredDevices().getDevicesFromType(device);
        if (!deviceList.isEmpty()) {
            deviceList.itemAt(0)->setName(String8(device_name));
            deviceList.itemAt(0)->mAddress = address;
            return deviceList.itemAt(0);
        }
    }

    sp<DeviceDescriptor> devDesc = new DeviceDescriptor(device);