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

Commit f6c9f187 authored by Jiabin Huang's avatar Jiabin Huang Committed by Automerger Merge Worker
Browse files

Merge "Support query encapsualtion modes and metadata types." into rvc-dev am: 05be7e51

Change-Id: Ie73eb4aa0c0dbd66ab91d16e722bc3e3499892fa
parents 946c2503 05be7e51
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -80,9 +80,28 @@ void DeviceDescriptorBase::toAudioPort(struct audio_port *port) const
    toAudioPortConfig(&port->active_config);
    port->id = mId;
    port->ext.device.type = mDeviceTypeAddr.mType;
    port->ext.device.encapsulation_modes = mEncapsulationModes;
    port->ext.device.encapsulation_metadata_types = mEncapsulationMetadataTypes;
    (void)audio_utils_strlcpy_zerofill(port->ext.device.address, mDeviceTypeAddr.getAddress());
}

status_t DeviceDescriptorBase::setEncapsulationModes(uint32_t encapsulationModes) {
    if ((encapsulationModes & ~AUDIO_ENCAPSULATION_MODE_ALL_POSITION_BITS) != 0) {
        return BAD_VALUE;
    }
    mEncapsulationModes = encapsulationModes & ~(1 << AUDIO_ENCAPSULATION_MODE_NONE);
    return NO_ERROR;
}

status_t DeviceDescriptorBase::setEncapsulationMetadataTypes(uint32_t encapsulationMetadataTypes) {
    if ((encapsulationMetadataTypes & ~AUDIO_ENCAPSULATION_METADATA_TYPE_ALL_POSITION_BITS) != 0) {
        return BAD_VALUE;
    }
    mEncapsulationMetadataTypes =
            encapsulationMetadataTypes & ~(1 << AUDIO_ENCAPSULATION_METADATA_TYPE_NONE);
    return NO_ERROR;
}

void DeviceDescriptorBase::dump(std::string *dst, int spaces, int index,
                                const char* extraInfo, bool verbose) const
{
@@ -98,6 +117,12 @@ void DeviceDescriptorBase::dump(std::string *dst, int spaces, int index,
    dst->append(base::StringPrintf("%*s- type: %-48s\n",
            spaces, "", ::android::toString(mDeviceTypeAddr.mType).c_str()));

    dst->append(base::StringPrintf(
            "%*s- supported encapsulation modes: %u", spaces, "", mEncapsulationModes));
    dst->append(base::StringPrintf(
            "%*s- supported encapsulation metadata types: %u",
            spaces, "", mEncapsulationMetadataTypes));

    if (mDeviceTypeAddr.mAddress.size() != 0) {
        dst->append(base::StringPrintf(
                "%*s- address: %-32s\n", spaces, "", mDeviceTypeAddr.getAddress()));
@@ -135,6 +160,8 @@ status_t DeviceDescriptorBase::writeToParcel(Parcel *parcel) const
    if ((status = AudioPort::writeToParcel(parcel)) != NO_ERROR) return status;
    if ((status = AudioPortConfig::writeToParcel(parcel)) != NO_ERROR) return status;
    if ((status = parcel->writeParcelable(mDeviceTypeAddr)) != NO_ERROR) return status;
    if ((status = parcel->writeUint32(mEncapsulationModes)) != NO_ERROR) return status;
    if ((status = parcel->writeUint32(mEncapsulationMetadataTypes)) != NO_ERROR) return status;
    return status;
}

@@ -144,6 +171,8 @@ status_t DeviceDescriptorBase::readFromParcel(const Parcel *parcel)
    if ((status = AudioPort::readFromParcel(parcel)) != NO_ERROR) return status;
    if ((status = AudioPortConfig::readFromParcel(parcel)) != NO_ERROR) return status;
    if ((status = parcel->readParcelable(&mDeviceTypeAddr)) != NO_ERROR) return status;
    if ((status = parcel->readUint32(&mEncapsulationModes)) != NO_ERROR) return status;
    if ((status = parcel->readUint32(&mEncapsulationMetadataTypes)) != NO_ERROR) return status;
    return status;
}

+5 −0
Original line number Diff line number Diff line
@@ -55,6 +55,9 @@ public:
    // AudioPort
    virtual void toAudioPort(struct audio_port *port) const;

    status_t setEncapsulationModes(uint32_t encapsulationModes);
    status_t setEncapsulationMetadataTypes(uint32_t encapsulationMetadataTypes);

    void dump(std::string *dst, int spaces, int index,
              const char* extraInfo = nullptr, bool verbose = true) const;
    void log() const;
@@ -67,6 +70,8 @@ public:

protected:
    AudioDeviceTypeAddr mDeviceTypeAddr;
    uint32_t mEncapsulationModes = 0;
    uint32_t mEncapsulationMetadataTypes = 0;
};

using DeviceDescriptorBaseVector = std::vector<sp<DeviceDescriptorBase>>;
+3 −0
Original line number Diff line number Diff line
@@ -131,6 +131,9 @@ TEST(AudioFoundationParcelableTest, ParcelingDeviceDescriptorBase) {
    desc->setAudioProfiles(getAudioProfileVectorForTest());
    desc->applyAudioPortConfig(&TEST_AUDIO_PORT_CONFIG);
    desc->setAddress("DeviceDescriptorBaseTestAddress");
    ASSERT_EQ(desc->setEncapsulationModes(1 << AUDIO_ENCAPSULATION_MODE_HANDLE), NO_ERROR);
    ASSERT_EQ(desc->setEncapsulationMetadataTypes(
            AUDIO_ENCAPSULATION_METADATA_TYPE_ALL_POSITION_BITS), NO_ERROR);

    ASSERT_EQ(data.writeParcelable(*desc), NO_ERROR);
    data.setDataPosition(0);
+13 −4
Original line number Diff line number Diff line
@@ -41,16 +41,25 @@ status_t ConversionHelperHidl::keysFromHal(const String8& keys, hidl_vec<hidl_st
    bool keepFormatValue = halKeys.size() == 2 &&
         (halKeys.get(String8(AudioParameter::keyStreamSupportedChannels), value) == NO_ERROR ||
         halKeys.get(String8(AudioParameter::keyStreamSupportedSamplingRates), value) == NO_ERROR);
    // When querying encapsulation capabilities, "keyRouting=<value>" pair is used to identify
    // the device. We need to transform it into a single key string so that it is carried over to
    // the legacy HAL via HIDL.
    bool keepRoutingValue =
            halKeys.get(String8(AUDIO_PARAMETER_DEVICE_SUP_ENCAPSULATION_MODES),
                        value) == NO_ERROR ||
            halKeys.get(String8(AUDIO_PARAMETER_DEVICE_SUP_ENCAPSULATION_METADATA_TYPES),
                        value) == NO_ERROR;

    for (size_t i = 0; i < halKeys.size(); ++i) {
        String8 key;
        status_t status = halKeys.getAt(i, key);
        if (status != OK) return status;
        if (keepFormatValue && key == AudioParameter::keyFormat) {
            AudioParameter formatParam;
        if ((keepFormatValue && key == AudioParameter::keyFormat) ||
            (keepRoutingValue && key == AudioParameter::keyRouting)) {
            AudioParameter keepValueParam;
            halKeys.getAt(i, key, value);
            formatParam.add(key, value);
            key = formatParam.toString();
            keepValueParam.add(key, value);
            key = keepValueParam.toString();
        }
        (*hidlKeys)[i] = key.string();
    }
+4 −0
Original line number Diff line number Diff line
@@ -53,6 +53,10 @@ const char * const AudioParameter::valueOff = AUDIO_PARAMETER_VALUE_OFF;
const char * const AudioParameter::valueListSeparator = AUDIO_PARAMETER_VALUE_LIST_SEPARATOR;
const char * const AudioParameter::keyReconfigA2dp = AUDIO_PARAMETER_RECONFIG_A2DP;
const char * const AudioParameter::keyReconfigA2dpSupported = AUDIO_PARAMETER_A2DP_RECONFIG_SUPPORTED;
// const char * const AudioParameter::keyDeviceSupportedEncapsulationModes =
//        AUDIO_PARAMETER_DEVICE_SUP_ENCAPSULATION_MODES;
// const char * const AudioParameter::keyDeviceSupportedEncapsulationMetadataTypes =
//        AUDIO_PARAMETER_DEVICE_SUP_ENCAPSULATION_METADATA_TYPES;

AudioParameter::AudioParameter(const String8& keyValuePairs)
{
Loading