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

Commit dbb12583 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes from topic "aosp-default-wrapper"

* changes:
  HidlUtils: remove temporary conversion functions
  audio: Update default effect HAL wrapper to support V7
  audio: Update default wrapper to support V7
  audio: Extend HidlUtils for the default wrapper needs
parents 276369a3 bae23366
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -66,9 +66,10 @@ interface IStream {
     * Retrieves basic stream configuration: sample rate, audio format,
     * channel mask.
     *
     * @return retval operation completion status.
     * @return config basic stream configuration.
     */
    getAudioProperties() generates (AudioConfigBase config);
    getAudioProperties() generates (Result retval, AudioConfigBase config);

    /**
     * Sets stream parameters. Only sets parameters that are specified.
+8 −0
Original line number Diff line number Diff line
@@ -225,6 +225,10 @@ static inline bool isUnknownAudioChannelMask(const std::string& mask) {
    return stringToAudioChannelMask(mask) == AudioChannelMask::UNKNOWN;
}

static inline bool isUnknownAudioContentType(const std::string& contentType) {
    return stringToAudioContentType(contentType) == AudioContentType::UNKNOWN;
}

static inline bool isUnknownAudioDevice(const std::string& device) {
    return stringToAudioDevice(device) == AudioDevice::UNKNOWN && !isVendorExtension(device);
}
@@ -237,6 +241,10 @@ static inline bool isUnknownAudioGainMode(const std::string& mode) {
    return stringToAudioGainMode(mode) == AudioGainMode::UNKNOWN;
}

static inline bool isUnknownAudioInOutFlag(const std::string& flag) {
    return stringToAudioInOutFlag(flag) == AudioInOutFlag::UNKNOWN;
}

static inline bool isUnknownAudioSource(const std::string& source) {
    return stringToAudioSource(source) == AudioSource::UNKNOWN;
}
+8 −8
Original line number Diff line number Diff line
@@ -107,12 +107,12 @@ Return<Result> Effect::setInputDevice(const DeviceAddress& device) {
}

Return<void> Effect::getConfig(getConfig_cb _hidl_cb) {
    const EffectConfig config = {{} /* inputCfg */,
    const EffectConfig config = {
            {} /* inputCfg */,
            // outputCfg
            {{} /* buffer */,
                                  48000 /* samplingRateHz */,
                                  toString(xsd::AudioChannelMask::AUDIO_CHANNEL_OUT_STEREO),
                                  toString(xsd::AudioFormat::AUDIO_FORMAT_PCM_16_BIT),
             {toString(xsd::AudioFormat::AUDIO_FORMAT_PCM_16_BIT), 48000 /* samplingRateHz */,
              toString(xsd::AudioChannelMask::AUDIO_CHANNEL_OUT_STEREO)}, /* base */
             EffectBufferAccess::ACCESS_ACCUMULATE,
             0 /* mask */}};
    _hidl_cb(Result::OK, config);
+59 −0
Original line number Diff line number Diff line
@@ -95,6 +95,25 @@ status_t HidlUtils::audioChannelMaskFromHal(audio_channel_mask_t halChannelMask,
    return NO_ERROR;
}

status_t HidlUtils::audioChannelMasksFromHal(const std::vector<std::string>& halChannelMasks,
                                             hidl_vec<AudioChannelMask>* channelMasks) {
    hidl_vec<AudioChannelMask> tempChannelMasks;
    tempChannelMasks.resize(halChannelMasks.size());
    size_t tempPos = 0;
    for (const auto& halChannelMask : halChannelMasks) {
        if (!halChannelMask.empty() && !xsd::isUnknownAudioChannelMask(halChannelMask)) {
            tempChannelMasks[tempPos++] = halChannelMask;
        }
    }
    if (tempPos == tempChannelMasks.size()) {
        *channelMasks = std::move(tempChannelMasks);
    } else {
        *channelMasks = hidl_vec<AudioChannelMask>(tempChannelMasks.begin(),
                                                   tempChannelMasks.begin() + tempPos);
    }
    return halChannelMasks.size() == channelMasks->size() ? NO_ERROR : BAD_VALUE;
}

status_t HidlUtils::audioChannelMaskToHal(const AudioChannelMask& channelMask,
                                          audio_channel_mask_t* halChannelMask) {
    if (!xsd::isUnknownAudioChannelMask(channelMask) &&
@@ -127,6 +146,28 @@ status_t HidlUtils::audioConfigBaseToHal(const AudioConfigBase& configBase,
    return result;
}

status_t HidlUtils::audioContentTypeFromHal(const audio_content_type_t halContentType,
                                            AudioContentType* contentType) {
    *contentType = audio_content_type_to_string(halContentType);
    if (!contentType->empty() && !xsd::isUnknownAudioContentType(*contentType)) {
        return NO_ERROR;
    }
    ALOGE("Unknown audio content type value 0x%X", halContentType);
    *contentType = toString(xsd::AudioContentType::AUDIO_CONTENT_TYPE_UNKNOWN);
    return BAD_VALUE;
}

status_t HidlUtils::audioContentTypeToHal(const AudioContentType& contentType,
                                          audio_content_type_t* halContentType) {
    if (!xsd::isUnknownAudioContentType(contentType) &&
        audio_content_type_from_string(contentType.c_str(), halContentType)) {
        return NO_ERROR;
    }
    ALOGE("Unknown audio content type \"%s\"", contentType.c_str());
    *halContentType = AUDIO_CONTENT_TYPE_UNKNOWN;
    return BAD_VALUE;
}

status_t HidlUtils::audioDeviceTypeFromHal(audio_devices_t halDevice, AudioDevice* device) {
    *device = audio_device_to_string(halDevice);
    if (!device->empty() && !xsd::isUnknownAudioDevice(*device)) {
@@ -155,6 +196,24 @@ status_t HidlUtils::audioFormatFromHal(audio_format_t halFormat, AudioFormat* fo
    return BAD_VALUE;
}

status_t HidlUtils::audioFormatsFromHal(const std::vector<std::string>& halFormats,
                                        hidl_vec<AudioFormat>* formats) {
    hidl_vec<AudioFormat> tempFormats;
    tempFormats.resize(halFormats.size());
    size_t tempPos = 0;
    for (const auto& halFormat : halFormats) {
        if (!halFormat.empty() && !xsd::isUnknownAudioFormat(halFormat)) {
            tempFormats[tempPos++] = halFormat;
        }
    }
    if (tempPos == tempFormats.size()) {
        *formats = std::move(tempFormats);
    } else {
        *formats = hidl_vec<AudioFormat>(tempFormats.begin(), tempFormats.begin() + tempPos);
    }
    return halFormats.size() == formats->size() ? NO_ERROR : BAD_VALUE;
}

status_t HidlUtils::audioFormatToHal(const AudioFormat& format, audio_format_t* halFormat) {
    if (!xsd::isUnknownAudioFormat(format) && audio_format_from_string(format.c_str(), halFormat)) {
        return NO_ERROR;
+2 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ filegroup {
    name: "android.hardware.audio.common-util@2-6",
    srcs: [
        "HidlUtils.cpp",
        "HidlUtilsCommon.cpp",
        "UuidUtils.cpp",
    ],
}
@@ -132,6 +133,7 @@ cc_library {
    defaults: ["android.hardware.audio.common-util_default"],
    srcs: [
        "7.0/HidlUtils.cpp",
        "HidlUtilsCommon.cpp",
        "UuidUtils.cpp",
    ],
    shared_libs: [
Loading