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

Commit 9fe93f2b authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 11828632 from e3396f81 to 24Q3-release

Change-Id: I83b760bc578309a369263c1595c8f4bff9d72542
parents f2f47312 e3396f81
Loading
Loading
Loading
Loading
+30 −30
Original line number Diff line number Diff line
@@ -79,7 +79,7 @@ inline std::ostream& operator<<(std::ostream& out, const RetCode& code) {
    do {                                                                                        \
        const ::ndk::ScopedAStatus curr_status = (status);                                      \
        if (!curr_status.isOk()) {                                                              \
            LOG(ERROR) << __func__ << ":" << __LINE__                                          \
            LOG(ERROR) << __func__ << ": line" << __LINE__                                      \
                       << " return with status: " << curr_status.getDescription() << (message); \
            return ndk::ScopedAStatus::fromExceptionCodeWithMessage(                            \
                    curr_status.getExceptionCode(), (message));                                 \
@@ -89,7 +89,7 @@ inline std::ostream& operator<<(std::ostream& out, const RetCode& code) {
#define RETURN_IF(expr, exception, message)                                                  \
    do {                                                                                     \
        if (expr) {                                                                          \
            LOG(ERROR) << __func__ << ":" << __LINE__ << " return with expr " << #expr;      \
            LOG(ERROR) << __func__ << ": line" << __LINE__ << " return with expr " << #expr; \
            return ndk::ScopedAStatus::fromExceptionCodeWithMessage((exception), (message)); \
        }                                                                                    \
    } while (0)
@@ -97,7 +97,7 @@ inline std::ostream& operator<<(std::ostream& out, const RetCode& code) {
#define RETURN_OK_IF(expr)                                                                  \
    do {                                                                                    \
        if (expr) {                                                                         \
            LOG(INFO) << __func__ << ":" << __LINE__ << " return with expr " << #expr; \
            LOG(INFO) << __func__ << ": line" << __LINE__ << " return with expr " << #expr; \
            return ndk::ScopedAStatus::ok();                                                \
        }                                                                                   \
    } while (0)
@@ -105,7 +105,7 @@ inline std::ostream& operator<<(std::ostream& out, const RetCode& code) {
#define RETURN_VALUE_IF(expr, ret, log)                                                       \
    do {                                                                                      \
        if (expr) {                                                                           \
            LOG(ERROR) << __func__ << ":" << __LINE__ << " return with expr \"" << #expr \
            LOG(ERROR) << __func__ << ": line" << __LINE__ << " return with expr \"" << #expr \
                       << "\":" << (log);                                                     \
            return ret;                                                                       \
        }                                                                                     \
+10 −0
Original line number Diff line number Diff line
@@ -64,7 +64,12 @@ namespace aidl::android::hardware::audio::effect {

const std::string SpatializerSw::kEffectName = "SpatializerSw";

const AudioChannelLayout kSupportedChannelMask =
        AudioChannelLayout::make<AudioChannelLayout::layoutMask>(
                AudioChannelLayout::LAYOUT_5POINT1);
const std::vector<Range::SpatializerRange> SpatializerSw::kRanges = {
        MAKE_RANGE(Spatializer, supportedChannelLayout, {kSupportedChannelMask},
                   {kSupportedChannelMask}),
        MAKE_RANGE(Spatializer, spatializationLevel, Spatialization::Level::NONE,
                   Spatialization::Level::BED_PLUS_OBJECTS),
        MAKE_RANGE(Spatializer, spatializationMode, Spatialization::Mode::BINAURAL,
@@ -133,6 +138,11 @@ ndk::ScopedAStatus SpatializerSw::getParameterSpecific(const Parameter::Id& id,
}

std::shared_ptr<EffectContext> SpatializerSw::createContext(const Parameter::Common& common) {
    if (common.input.base.channelMask != kSupportedChannelMask) {
        LOG(ERROR) << __func__
                   << " channelMask not supported: " << common.input.base.channelMask.toString();
        return nullptr;
    }
    if (mContext) {
        LOG(DEBUG) << __func__ << " context already exist";
    } else {
+40 −14
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@

#include <algorithm>
#include <memory>
#include <optional>
#include <string>
#include <type_traits>
#include <unordered_map>
@@ -42,13 +43,18 @@
using namespace android;
using aidl::android::hardware::audio::effect::CommandId;
using aidl::android::hardware::audio::effect::Descriptor;
using aidl::android::hardware::audio::effect::getEffectTypeUuidSpatializer;
using aidl::android::hardware::audio::effect::getRange;
using aidl::android::hardware::audio::effect::IEffect;
using aidl::android::hardware::audio::effect::isRangeValid;
using aidl::android::hardware::audio::effect::kEffectTypeUuidSpatializer;
using aidl::android::hardware::audio::effect::kEventFlagDataMqNotEmpty;
using aidl::android::hardware::audio::effect::kEventFlagDataMqUpdate;
using aidl::android::hardware::audio::effect::kEventFlagNotEmpty;
using aidl::android::hardware::audio::effect::kReopenSupportedVersion;
using aidl::android::hardware::audio::effect::Parameter;
using aidl::android::hardware::audio::effect::Range;
using aidl::android::hardware::audio::effect::Spatializer;
using aidl::android::hardware::audio::effect::State;
using aidl::android::hardware::common::fmq::SynchronizedReadWrite;
using aidl::android::media::audio::common::AudioChannelLayout;
@@ -79,7 +85,7 @@ static inline std::string getPrefix(Descriptor& descriptor) {

class EffectHelper {
  public:
    static void create(std::shared_ptr<IFactory> factory, std::shared_ptr<IEffect>& effect,
    void create(std::shared_ptr<IFactory> factory, std::shared_ptr<IEffect>& effect,
                Descriptor& desc, binder_status_t status = EX_NONE) {
        ASSERT_NE(factory, nullptr);
        auto& id = desc.common.id;
@@ -87,6 +93,8 @@ class EffectHelper {
        if (status == EX_NONE) {
            ASSERT_NE(effect, nullptr) << toString(id.uuid);
        }
        mIsSpatializer = id.type == getEffectTypeUuidSpatializer();
        mDescriptor = desc;
    }

    static void destroyIgnoreRet(std::shared_ptr<IFactory> factory,
@@ -110,10 +118,9 @@ class EffectHelper {
        ASSERT_STATUS(status, effect->open(common, specific, ret));
    }

    static void open(std::shared_ptr<IEffect> effect, int session = 0,
                     binder_status_t status = EX_NONE) {
    void open(std::shared_ptr<IEffect> effect, int session = 0, binder_status_t status = EX_NONE) {
        ASSERT_NE(effect, nullptr);
        Parameter::Common common = EffectHelper::createParamCommon(session);
        Parameter::Common common = createParamCommon(session);
        IEffect::OpenEffectReturn ret;
        ASSERT_NO_FATAL_FAILURE(open(effect, common, std::nullopt /* specific */, &ret, status));
    }
@@ -207,15 +214,31 @@ class EffectHelper {
                                               true /* retry */));
        EXPECT_TRUE(efState & kEventFlagDataMqUpdate);
    }
    static Parameter::Common createParamCommon(
            int session = 0, int ioHandle = -1, int iSampleRate = 48000, int oSampleRate = 48000,
            long iFrameCount = 0x100, long oFrameCount = 0x100,
            AudioChannelLayout inputChannelLayout =
                    AudioChannelLayout::make<AudioChannelLayout::layoutMask>(
                            AudioChannelLayout::LAYOUT_STEREO),
            AudioChannelLayout outputChannelLayout =
                    AudioChannelLayout::make<AudioChannelLayout::layoutMask>(
                            AudioChannelLayout::LAYOUT_STEREO)) {

    Parameter::Common createParamCommon(int session = 0, int ioHandle = -1, int iSampleRate = 48000,
                                        int oSampleRate = 48000, long iFrameCount = 0x100,
                                        long oFrameCount = 0x100) {
        AudioChannelLayout defaultLayout = AudioChannelLayout::make<AudioChannelLayout::layoutMask>(
                AudioChannelLayout::LAYOUT_STEREO);
        // query supported input layout and use it as the default parameter in common
        if (mIsSpatializer && isRangeValid<Range::spatializer>(Spatializer::supportedChannelLayout,
                                                               mDescriptor.capability)) {
            const auto layoutRange = getRange<Range::spatializer, Range::SpatializerRange>(
                    mDescriptor.capability, Spatializer::supportedChannelLayout);
            if (std::vector<AudioChannelLayout> layouts;
                layoutRange &&
                0 != (layouts = layoutRange->min.get<Spatializer::supportedChannelLayout>())
                                .size()) {
                defaultLayout = layouts[0];
            }
        }
        return createParamCommon(session, ioHandle, iSampleRate, oSampleRate, iFrameCount,
                                 oFrameCount, defaultLayout, defaultLayout);
    }
    static Parameter::Common createParamCommon(int session, int ioHandle, int iSampleRate,
                                               int oSampleRate, long iFrameCount, long oFrameCount,
                                               AudioChannelLayout inputChannelLayout,
                                               AudioChannelLayout outputChannelLayout) {
        Parameter::Common common;
        common.session = session;
        common.ioHandle = ioHandle;
@@ -379,4 +402,7 @@ class EffectHelper {

        return bufferMag;
    }

    bool mIsSpatializer;
    Descriptor mDescriptor;
};
+1 −1
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ class AECParamTest : public ::testing::TestWithParam<AECParamTestParam>, public
        ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));

        auto specific = getDefaultParamSpecific();
        Parameter::Common common = EffectHelper::createParamCommon(
        Parameter::Common common = createParamCommon(
                0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */,
                kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */);
        IEffect::OpenEffectReturn ret;
+1 −1
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ class AGC1ParamTest : public ::testing::TestWithParam<AGC1ParamTestParam>, publi
        ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));

        Parameter::Specific specific = getDefaultParamSpecific();
        Parameter::Common common = EffectHelper::createParamCommon(
        Parameter::Common common = createParamCommon(
                0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */,
                kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */);
        IEffect::OpenEffectReturn ret;
Loading