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

Commit 61b571ab authored by Shunkai Yao's avatar Shunkai Yao
Browse files

Preserve previous control parameters with common AIDL parameter setting

make sure the initial volume setting not lost

Flag: EXEMPT bugfix
Bug: 374157658
Test: HapticGenerator testing app
Test: atest CtsMediaAudioTestCases
Change-Id: I20ab2e878a3bb6ef422a2021150a9b7b7f5ee110
parent 9d6fa955
Loading
Loading
Loading
Loading
+20 −2
Original line number Diff line number Diff line
@@ -93,7 +93,18 @@ void BundleContext::deInit() {
RetCode BundleContext::setCommon(const Parameter::Common& common) {
    RetCode ret = EffectContext::setCommon(common);
    RETURN_VALUE_IF(ret != RetCode::SUCCESS, ret, " setCommonFailed");
    return init();
    if (mInstance) {
        LVM_ControlParams_t params;
        RETURN_VALUE_IF(LVM_SUCCESS != LVM_GetControlParameters(mInstance, &params),
                        RetCode::ERROR_EFFECT_LIB_ERROR, "failGetControlParams");
        RETURN_VALUE_IF(RetCode::SUCCESS != applyCommonParameter(params),
                        RetCode::ERROR_EFFECT_LIB_ERROR, " applyCommonParameterFailed");
        RETURN_VALUE_IF(LVM_SUCCESS != LVM_SetControlParameters(mInstance, &params),
                        RetCode::ERROR_EFFECT_LIB_ERROR, "failSetControlParams");
    } else {
        RETURN_VALUE_IF(RetCode::SUCCESS != init(), RetCode::ERROR_EFFECT_LIB_ERROR, " initFailed");
    }
    return RetCode::SUCCESS;
}

RetCode BundleContext::enable() {
@@ -605,7 +616,7 @@ RetCode BundleContext::setForcedDevice(
    return ret;
}

RetCode BundleContext::initControlParameter(LVM_ControlParams_t& params) const {
RetCode BundleContext::applyCommonParameter(LVM_ControlParams_t& params) const {
    int outputChannelCount = ::aidl::android::hardware::audio::common::getChannelCount(
            mCommon.output.base.channelMask);
    auto outputChannelMaskConv = aidl2legacy_AudioChannelLayout_audio_channel_mask_t(
@@ -627,6 +638,13 @@ RetCode BundleContext::initControlParameter(LVM_ControlParams_t& params) const {
        params.SourceFormat = LVM_MULTICHANNEL;
    }

    return RetCode::SUCCESS;
}

RetCode BundleContext::initControlParameter(LVM_ControlParams_t& params) const {
    RETURN_VALUE_IF(RetCode::SUCCESS != applyCommonParameter(params),
                    RetCode::ERROR_EFFECT_LIB_ERROR, " applyCommonParameterFailed");

    /* General parameters */
    params.OperatingMode = LVM_MODE_ON;
    params.SpeakerType = LVM_HEADPHONES;
+1 −0
Original line number Diff line number Diff line
@@ -135,6 +135,7 @@ class BundleContext final : public EffectContext {
    bool isBandLevelIndexInRange(const std::vector<Equalizer::BandLevel>& bandLevels) const;
    static LVM_EQNB_BandDef_t* getDefaultEqualizerBandDefs();
    static LVM_HeadroomBandDef_t* getDefaultEqualizerHeadroomBanDefs();
    RetCode applyCommonParameter(LVM_ControlParams_t& params) const;
};

}  // namespace aidl::android::hardware::audio::effect