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

Commit f3aaf48f authored by Eric Laurent's avatar Eric Laurent Committed by Android (Google) Code Review
Browse files

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

parents 7e52fc60 634b7147
Loading
Loading
Loading
Loading
+0 −2
Original line number Original line Diff line number Diff line
@@ -84,8 +84,6 @@ public:


    audio_devices_t getDevicesFromHwModule(audio_module_handle_t moduleHandle) const;
    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;
    status_t dump(int fd, const String8 &tag, int spaces = 0, bool verbose = true) const;


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


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


    status_t dump(int fd) const;
    status_t dump(int fd) const;
};
};
+0 −6
Original line number Original line 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;
    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,
void DeviceDescriptor::toAudioPortConfig(struct audio_port_config *dstConfig,
                                         const struct audio_port_config *srcConfig) const
                                         const struct audio_port_config *srcConfig) const
{
{
+10 −3
Original line number Original line 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,
sp<DeviceDescriptor>  HwModuleCollection::getDeviceDescriptor(const audio_devices_t device,
                                                              const char *device_address,
                                                              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);
    String8 address = (device_address == NULL) ? String8("") : String8(device_address);
    // handle legacy remote submix case where the address was not always specified
    // 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) {
        if (hwModule->mHandle == 0) {
            continue;
            continue;
        }
        }
        DeviceVector deviceList =
        DeviceVector declaredDevices = hwModule->getDeclaredDevices();
                hwModule->getDeclaredDevices().getDevicesFromTypeAddr(device, address);
        DeviceVector deviceList = declaredDevices.getDevicesFromTypeAddr(device, address);
        if (!deviceList.isEmpty()) {
        if (!deviceList.isEmpty()) {
            return deviceList.itemAt(0);
            return deviceList.itemAt(0);
        }
        }
        if (!matchAdress) {
            deviceList = declaredDevices.getDevicesFromType(device);
            if (!deviceList.isEmpty()) {
                return deviceList.itemAt(0);
            }
        }
    }
    }


    sp<DeviceDescriptor> devDesc = new DeviceDescriptor(device);
    sp<DeviceDescriptor> devDesc = new DeviceDescriptor(device);
+12 −2
Original line number Original line 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,
audio_policy_dev_state_t AudioPolicyManager::getDeviceConnectionState(audio_devices_t device,
                                                                      const char *device_address)
                                                                      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;
    DeviceVector *deviceVector;


@@ -303,7 +311,9 @@ audio_policy_dev_state_t AudioPolicyManager::getDeviceConnectionState(audio_devi
        ALOGW("getDeviceConnectionState() invalid device type %08x", device);
        ALOGW("getDeviceConnectionState() invalid device type %08x", device);
        return AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE;
        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)
void AudioPolicyManager::updateCallRouting(audio_devices_t rxDevice, int delayMs)