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

Commit 93b686a2 authored by Eric Laurent's avatar Eric Laurent Committed by android-build-merger
Browse files

Merge "audio policy: fix regression in getDeviceConnectionState()." into nyc-dev

am: f3aaf48f

* commit 'f3aaf48f':
  audio policy: fix regression in getDeviceConnectionState().

Change-Id: Ibcb4beac0721b5e5289cfec6ccbf46fb379910a5
parents 15f69419 f3aaf48f
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -84,8 +84,6 @@ public:

    audio_devices_t getDevicesFromHwModule(audio_module_handle_t moduleHandle) const;

    audio_policy_dev_state_t getDeviceConnectionState(const sp<DeviceDescriptor> &devDesc) const;

    status_t dump(int fd, const String8 &tag, int spaces = 0, bool verbose = true) const;

private:
+2 −1
Original line number Diff line number Diff line
@@ -106,7 +106,8 @@ public:

    sp<DeviceDescriptor> getDeviceDescriptor(const audio_devices_t device,
                                             const char *device_address,
                                             const char *device_name) const;
                                             const char *device_name,
                                             bool matchAdress = true) const;

    status_t dump(int fd) const;
};
+0 −6
Original line number Diff line number Diff line
@@ -219,12 +219,6 @@ status_t DeviceVector::dump(int fd, const String8 &tag, int spaces, bool verbose
    return NO_ERROR;
}

audio_policy_dev_state_t DeviceVector::getDeviceConnectionState(const sp<DeviceDescriptor> &devDesc) const
{
    ssize_t index = indexOf(devDesc);
    return index >= 0 ? AUDIO_POLICY_DEVICE_STATE_AVAILABLE : AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE;
}

void DeviceDescriptor::toAudioPortConfig(struct audio_port_config *dstConfig,
                                         const struct audio_port_config *srcConfig) const
{
+10 −3
Original line number Diff line number Diff line
@@ -292,7 +292,8 @@ sp <HwModule> HwModuleCollection::getModuleForDevice(audio_devices_t device) con

sp<DeviceDescriptor>  HwModuleCollection::getDeviceDescriptor(const audio_devices_t device,
                                                              const char *device_address,
                                                              const char *device_name) const
                                                              const char *device_name,
                                                              bool matchAdress) const
{
    String8 address = (device_address == NULL) ? String8("") : String8(device_address);
    // handle legacy remote submix case where the address was not always specified
@@ -305,11 +306,17 @@ sp<DeviceDescriptor> HwModuleCollection::getDeviceDescriptor(const audio_device
        if (hwModule->mHandle == 0) {
            continue;
        }
        DeviceVector deviceList =
                hwModule->getDeclaredDevices().getDevicesFromTypeAddr(device, address);
        DeviceVector declaredDevices = hwModule->getDeclaredDevices();
        DeviceVector deviceList = declaredDevices.getDevicesFromTypeAddr(device, address);
        if (!deviceList.isEmpty()) {
            return deviceList.itemAt(0);
        }
        if (!matchAdress) {
            deviceList = declaredDevices.getDevicesFromType(device);
            if (!deviceList.isEmpty()) {
                return deviceList.itemAt(0);
            }
        }
    }

    sp<DeviceDescriptor> devDesc = new DeviceDescriptor(device);
+12 −2
Original line number Diff line number Diff line
@@ -291,7 +291,15 @@ status_t AudioPolicyManager::setDeviceConnectionStateInt(audio_devices_t device,
audio_policy_dev_state_t AudioPolicyManager::getDeviceConnectionState(audio_devices_t device,
                                                                      const char *device_address)
{
    sp<DeviceDescriptor> devDesc = mHwModules.getDeviceDescriptor(device, device_address, "");
    sp<DeviceDescriptor> devDesc =
            mHwModules.getDeviceDescriptor(device, device_address, "",
                                           (strlen(device_address) != 0)/*matchAddress*/);

    if (devDesc == 0) {
        ALOGW("getDeviceConnectionState() undeclared device, type %08x, address: %s",
              device, device_address);
        return AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE;
    }

    DeviceVector *deviceVector;

@@ -303,7 +311,9 @@ audio_policy_dev_state_t AudioPolicyManager::getDeviceConnectionState(audio_devi
        ALOGW("getDeviceConnectionState() invalid device type %08x", device);
        return AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE;
    }
    return deviceVector->getDeviceConnectionState(devDesc);

    return (deviceVector->getDevice(device, String8(device_address)) != 0) ?
            AUDIO_POLICY_DEVICE_STATE_AVAILABLE : AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE;
}

void AudioPolicyManager::updateCallRouting(audio_devices_t rxDevice, int delayMs)