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

Commit 33face9c authored by Shunkai Yao's avatar Shunkai Yao Committed by Gerrit Code Review
Browse files

Merge changes from topic "backward_compatibility" into main

* changes:
  Backward compatibility in libAudioHal for effect AIDL v2
  Add backward compatibility in effect hal default implementation
parents 2a4da891 e317e334
Loading
Loading
Loading
Loading
+17 −7
Original line number Diff line number Diff line
@@ -57,20 +57,22 @@ using ::aidl::android::hardware::audio::effect::Descriptor;
using ::aidl::android::hardware::audio::effect::IEffect;
using ::aidl::android::hardware::audio::effect::IFactory;
using ::aidl::android::hardware::audio::effect::kEventFlagDataMqUpdate;
using ::aidl::android::hardware::audio::effect::kReopenSupportedVersion;
using ::aidl::android::hardware::audio::effect::State;

namespace android {
namespace effect {

EffectHalAidl::EffectHalAidl(const std::shared_ptr<IFactory>& factory,
                             const std::shared_ptr<IEffect>& effect,
                             int32_t sessionId, int32_t ioId, const Descriptor& desc,
                             bool isProxyEffect)
                             const std::shared_ptr<IEffect>& effect, int32_t sessionId,
                             int32_t ioId, const Descriptor& desc, bool isProxyEffect)
    : mFactory(factory),
      mEffect(effect),
      mSessionId(sessionId),
      mIoId(ioId),
      mIsProxyEffect(isProxyEffect) {
    assert(mFactory != nullptr);
    assert(mEffect != nullptr);
    createAidlConversion(effect, sessionId, ioId, desc);
}

@@ -184,10 +186,18 @@ status_t EffectHalAidl::process() {
        return INVALID_OPERATION;
    }

    if (uint32_t efState = 0;
        ::android::OK == efGroup->wait(kEventFlagDataMqUpdate, &efState, 1 /* ns */,
                                       true /* retry */)) {
        ALOGI("%s %s receive dataMQUpdate eventFlag from HAL", __func__, effectName.c_str());
    // use IFactory HAL version because IEffect can be an EffectProxy instance
    static const int halVersion = [&]() {
        int version = 0;
        return mFactory->getInterfaceVersion(&version).isOk() ? version : 0;
    }();

    if (uint32_t efState = 0; halVersion >= kReopenSupportedVersion &&
                              ::android::OK == efGroup->wait(kEventFlagDataMqUpdate, &efState,
                                                             1 /* ns */, true /* retry */) &&
                              efState & kEventFlagDataMqUpdate) {
        ALOGI("%s %s V%d receive dataMQUpdate eventFlag from HAL", __func__, effectName.c_str(),
              halVersion);
        mConversion->reopen();
    }
    auto statusQ = mConversion->getStatusMQ();
+4 −0
Original line number Diff line number Diff line
@@ -215,6 +215,10 @@ ndk::ScopedAStatus DynamicsProcessingImpl::open(const Parameter::Common& common,
    RETURN_OK_IF(mState != State::INIT);
    mImplContext = createContext(common);
    RETURN_IF(!mContext || !mImplContext, EX_NULL_POINTER, "createContextFailed");
    int version = 0;
    RETURN_IF(!getInterfaceVersion(&version).isOk(), EX_UNSUPPORTED_OPERATION,
              "FailedToGetInterfaceVersion");
    mImplContext->setVersion(version);
    mEventFlag = mImplContext->getStatusEventFlag();

    if (specific.has_value()) {
+2 −2
Original line number Diff line number Diff line
@@ -61,8 +61,8 @@ const std::vector<Range::VisualizerRange> VisualizerImpl::kRanges = {
        MAKE_RANGE(Visualizer, latencyMs, 0, VisualizerContext::kMaxLatencyMs),
        MAKE_RANGE(Visualizer, captureSamples, 0, VisualizerContext::kMaxCaptureBufSize),
        /* get only parameters, set invalid range (min > max) to indicate not support set */
        MAKE_RANGE(Visualizer, measurement, Visualizer::Measurement({.peak = 1, .rms = 1}),
                   Visualizer::Measurement({.peak = 0, .rms = 0})),
        MAKE_RANGE(Visualizer, measurement, Visualizer::Measurement({.rms = 1, .peak = 1}),
                   Visualizer::Measurement({.rms = 0, .peak = 0})),
        MAKE_RANGE(Visualizer, captureSampleBuffer, std::vector<uint8_t>({1}),
                   std::vector<uint8_t>({0}))};
const Capability VisualizerImpl::kCapability = {