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

Commit 45e693df authored by Shunkai Yao's avatar Shunkai Yao
Browse files

libaudiohal: only update data FMQ with reopen

Bug: 302036943
Test: atest audioeffect_analysis
Change-Id: I756c9717d2d5658e9391b8f4d941ef1aa23fb3c1
parent edb2f14e
Loading
Loading
Loading
Loading
+15 −14
Original line number Diff line number Diff line
@@ -187,13 +187,7 @@ status_t EffectConversionHelperAidl::handleSetConfig(uint32_t cmdSize, const voi
        IEffect::OpenEffectReturn openReturn;
        RETURN_STATUS_IF_ERROR(
                statusTFromBinderStatus(mEffect->open(common, std::nullopt, &openReturn)));
        updateMqs(openReturn);

        if (status_t status = updateEventFlags(); status != OK) {
            ALOGV("%s closing at status %d", __func__, status);
            mEffect->close();
            return status;
        }
        updateMqsAndEventFlags(openReturn);
    } else if (mCommon != common) {
        ALOGI("%s at state %s, setParameter", __func__, android::internal::ToString(state).c_str());
        Parameter aidlParam = UNION_MAKE(Parameter, common, common);
@@ -204,13 +198,21 @@ status_t EffectConversionHelperAidl::handleSetConfig(uint32_t cmdSize, const voi
    return *static_cast<int32_t*>(pReplyData) = OK;
}

void EffectConversionHelperAidl::updateMqs(const IEffect::OpenEffectReturn& ret) {
void EffectConversionHelperAidl::updateMqsAndEventFlags(const IEffect::OpenEffectReturn& ret) {
    if (mIsProxyEffect) {
        mStatusQ = std::static_pointer_cast<EffectProxy>(mEffect)->getStatusMQ();
    } else {
        mStatusQ = std::make_shared<StatusMQ>(ret.statusMQ);
    }
    updateEventFlags();
    updateDataMqs(ret);
}

void EffectConversionHelperAidl::updateDataMqs(const IEffect::OpenEffectReturn& ret) {
    if (mIsProxyEffect) {
        mInputQ = std::static_pointer_cast<EffectProxy>(mEffect)->getInputMQ();
        mOutputQ = std::static_pointer_cast<EffectProxy>(mEffect)->getOutputMQ();
    } else {
        mStatusQ = std::make_shared<StatusMQ>(ret.statusMQ);
        mInputQ = std::make_shared<DataMQ>(ret.inputDataMQ);
        mOutputQ = std::make_shared<DataMQ>(ret.outputDataMQ);
    }
@@ -407,10 +409,8 @@ status_t EffectConversionHelperAidl::handleSetOffload(uint32_t cmdSize, const vo
        }
        // update FMQs if the effect instance already open
        if (State state; effectProxy->getState(&state).isOk() && state != State::INIT) {
            mStatusQ = effectProxy->getStatusMQ();
            mInputQ = effectProxy->getInputMQ();
            mOutputQ = effectProxy->getOutputMQ();
            updateEventFlags();
            IEffect::OpenEffectReturn openReturn;
            updateMqsAndEventFlags(openReturn);
        }
    }
    return *static_cast<int32_t*>(pReplyData) = OK;
@@ -512,7 +512,8 @@ status_t EffectConversionHelperAidl::reopen() {
    IEffect::OpenEffectReturn openReturn;
    RETURN_STATUS_IF_ERROR(statusTFromBinderStatus(mEffect->reopen(&openReturn)));

    updateMqs(openReturn);
    // status MQ won't be changed after open
    updateDataMqs(openReturn);
    return OK;
}

+4 −3
Original line number Diff line number Diff line
@@ -98,7 +98,6 @@ class EffectConversionHelperAidl {
    std::shared_ptr<StatusMQ> mStatusQ = nullptr;
    std::shared_ptr<DataMQ> mInputQ = nullptr, mOutputQ = nullptr;


    struct EventFlagDeleter {
        void operator()(::android::hardware::EventFlag* flag) const {
            if (flag) {
@@ -108,8 +107,10 @@ class EffectConversionHelperAidl {
    };
    std::shared_ptr<android::hardware::EventFlag> mEfGroup = nullptr;
    status_t updateEventFlags();

    void updateMqs(const ::aidl::android::hardware::audio::effect::IEffect::OpenEffectReturn& ret);
    void updateDataMqs(
            const ::aidl::android::hardware::audio::effect::IEffect::OpenEffectReturn& ret);
    void updateMqsAndEventFlags(
            const ::aidl::android::hardware::audio::effect::IEffect::OpenEffectReturn& ret);

    status_t handleInit(uint32_t cmdSize, const void* pCmdData, uint32_t* replySize,
                        void* pReplyData);