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

Commit 3c3995d4 authored by Vlad Popa's avatar Vlad Popa
Browse files

CSD: fix the logic for setting RS2 max value

The RS2 value is used for sendin momentary exposure warnings.

Test: atest SoundDoseHelperTest
Bug: 248565894
Change-Id: Ia4567e8a0efe55c75bd58d41a08c064534dd6813
parent 428c2798
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -116,23 +116,26 @@ void SoundDoseManager::setOutputRs2(float rs2Value) {
    ALOGV("%s", __func__);
    std::lock_guard _l(mLock);

    mRs2Value = rs2Value;
    if (mHalSoundDose != nullptr) {
        // using the HAL sound dose interface
        if (!mHalSoundDose->setOutputRs2(mRs2Value).isOk()) {
            ALOGE("%s: Cannot set RS2 value for momentary exposure %f", __func__, mRs2Value);
        if (!mHalSoundDose->setOutputRs2(rs2Value).isOk()) {
            ALOGE("%s: Cannot set RS2 value for momentary exposure %f", __func__, rs2Value);
            return;
        }
        mRs2Value = rs2Value;
        return;
    }

    for (auto& streamProcessor : mActiveProcessors) {
        sp<audio_utils::MelProcessor> processor = streamProcessor.second.promote();
        if (processor != nullptr) {
            status_t result = processor->setOutputRs2(mRs2Value);
            status_t result = processor->setOutputRs2(rs2Value);
            if (result != NO_ERROR) {
                ALOGW("%s: could not set RS2 value %f for stream %d", __func__, mRs2Value,
                ALOGW("%s: could not set RS2 value %f for stream %d", __func__, rs2Value,
                      streamProcessor.first);
                return;
            }
            mRs2Value = rs2Value;
        }
    }
}