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

Commit cc4a76d2 authored by Shunkai Yao's avatar Shunkai Yao Committed by Android (Google) Code Review
Browse files

Revert "Implement VolToDb with audio_utils_power_from_amplitude"

This reverts commit 9a0d5e01.

Reason for revert: DroidMonitor: Potential culprit for b/288445440 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.

Change-Id: Idf2a9826e0c9014e46bf3585ffccdac897ebdb89
parent 9a0d5e01
Loading
Loading
Loading
Loading
+19 −16
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@

#define LOG_TAG "BundleContext"
#include <android-base/logging.h>
#include <audio_utils/power.h>
#include <Utils.h>

#include "BundleContext.h"
@@ -398,10 +397,15 @@ LVM_INT16 BundleContext::LVC_ToDB_s32Tos16(LVM_INT32 Lin_fix) const {
    return db_fix;
}

/* static */
float BundleContext::VolToDb(float vol) {
    float dB = audio_utils_power_from_amplitude(vol);
    return std::max(dB, -96.f);
// TODO: replace with more generic approach, like: audio_utils_power_from_amplitude
int16_t BundleContext::VolToDb(uint32_t vol) const {
    int16_t dB;

    dB = LVC_ToDB_s32Tos16(vol << 7);
    dB = (dB + 8) >> 4;
    dB = (dB < -96) ? -96 : dB;

    return dB;
}

RetCode BundleContext::setVolumeStereo(const Parameter::VolumeStereo& volume) {
@@ -409,12 +413,11 @@ RetCode BundleContext::setVolumeStereo(const Parameter::VolumeStereo& volume) {
    LVM_ReturnStatus_en status = LVM_SUCCESS;

    // Convert volume to dB
    float leftdB = VolToDb(volume.left);
    float rightdB = VolToDb(volume.right);

    float maxdB = std::max(leftdB, rightdB);
    float pandB = rightdB - leftdB;
    setVolumeLevel(maxdB);
    int leftdB = VolToDb(volume.left);
    int rightdB = VolToDb(volume.right);
    int maxdB = std::max(leftdB, rightdB);
    int pandB = rightdB - leftdB;
    setVolumeLevel(maxdB * 100);
    LOG(DEBUG) << __func__ << " pandB: " << pandB << " maxdB " << maxdB;

    {
@@ -548,18 +551,18 @@ RetCode BundleContext::setBassBoostStrength(int strength) {
    return limitLevel();
}

RetCode BundleContext::setVolumeLevel(float level) {
RetCode BundleContext::setVolumeLevel(int level) {
    if (mMuteEnabled) {
        mLevelSaved = level;
        mLevelSaved = level / 100;
    } else {
        mVolume = level;
        mVolume = level / 100;
    }
    LOG(INFO) << __func__ << " success with level " << level;
    return limitLevel();
}

float BundleContext::getVolumeLevel() const {
    return (mMuteEnabled ? mLevelSaved : mVolume);
int BundleContext::getVolumeLevel() const {
    return (mMuteEnabled ? mLevelSaved * 100 : mVolume * 100);
}

RetCode BundleContext::setVolumeMute(bool mute) {
+5 −5
Original line number Diff line number Diff line
@@ -80,8 +80,8 @@ class BundleContext final : public EffectContext {
    RetCode setBassBoostStrength(int strength);
    int getBassBoostStrength() const { return mBassStrengthSaved; }

    RetCode setVolumeLevel(float level);
    float getVolumeLevel() const;
    RetCode setVolumeLevel(int level);
    int getVolumeLevel() const;

    RetCode setVolumeMute(bool mute);
    int getVolumeMute() const { return mMuteEnabled; }
@@ -141,14 +141,14 @@ class BundleContext final : public EffectContext {
    bool mVirtualizerTempDisabled = false;
    ::aidl::android::media::audio::common::AudioDeviceDescription mForceDevice;
    // Volume
    float mLevelSaved = 0; /* for when mute is set, level must be saved */
    float mVolume = 0;
    int mLevelSaved = 0; /* for when mute is set, level must be saved */
    int mVolume = 0;
    bool mMuteEnabled = false; /* Must store as mute = -96dB level */

    void initControlParameter(LVM_ControlParams_t& params) const;
    void initHeadroomParameter(LVM_HeadroomParams_t& params) const;
    RetCode limitLevel();
    static float VolToDb(float vol);
    int16_t VolToDb(uint32_t vol) const;
    LVM_INT16 LVC_ToDB_s32Tos16(LVM_INT32 Lin_fix) const;
    RetCode updateControlParameter(const std::vector<Equalizer::BandLevel>& bandLevels);
    bool isBandLevelIndexInRange(const std::vector<Equalizer::BandLevel>& bandLevels) const;
+1 −1
Original line number Diff line number Diff line
@@ -355,7 +355,7 @@ ndk::ScopedAStatus EffectBundleAidl::getParameterVolume(const Volume::Id& id,
    auto tag = id.get<Volume::Id::commonTag>();
    switch (tag) {
        case Volume::levelDb: {
            volParam.set<Volume::levelDb>(static_cast<int>(mContext->getVolumeLevel()));
            volParam.set<Volume::levelDb>(mContext->getVolumeLevel());
            break;
        }
        case Volume::mute: {