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

Commit 36fee4d4 authored by Lais Andrade's avatar Lais Andrade Committed by Automerger Merge Worker
Browse files

Merge "Revert "EnvironmentalReverb: Add AIDL placeholder implementation and...

Merge "Revert "EnvironmentalReverb: Add AIDL placeholder implementation and its unit test"" am: 95aa48b4 am: 41942ae0 am: cad91e61

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2361872



Change-Id: Ic3613c2e3a284b5a7058efed1f319b3478bf9e32
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 0e3dcf88 cad91e61
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -12,9 +12,6 @@
    {
      "name": "VtsHalDownmixTargetTest"
    },
    {
      "name": "VtsHalEnvironmentalReverbTargetTest"
    },
    {
      "name": "VtsHalEqualizerTargetTest"
    },
+0 −16
Original line number Diff line number Diff line
@@ -44,22 +44,6 @@ union EnvironmentalReverb {
  int diffusionPm;
  int densityPm;
  boolean bypass;
  const int MIN_ROOM_LEVEL_MB = -6000;
  const int MAX_ROOM_LEVEL_MB = 0;
  const int MIN_ROOM_HF_LEVEL_MB = -4000;
  const int MAX_ROOM_HF_LEVEL_MB = 0;
  const int MIN_DECAY_TIME_MS = 100;
  const int MAX_DECAY_TIME_MS = 20000;
  const int MIN_DECAY_HF_RATIO_PM = 100;
  const int MAX_DECAY_HF_RATIO_PM = 1000;
  const int MIN_LEVEL_MB = -6000;
  const int MAX_LEVEL_MB = 0;
  const int MIN_DELAY_MS = 0;
  const int MAX_DELAY_MS = 65;
  const int MIN_DIFFUSION_PM = 0;
  const int MAX_DIFFUSION_PM = 1000;
  const int MIN_DENSITY_PM = 0;
  const int MAX_DENSITY_PM = 1000;
  @VintfStability
  union Id {
    int vendorExtensionTag;
+0 −72
Original line number Diff line number Diff line
@@ -55,110 +55,38 @@ union EnvironmentalReverb {
        int maxDecayTimeMs;
    }

    /**
     * Minimal possible room level in millibels.
     */
    const int MIN_ROOM_LEVEL_MB = -6000;
    /**
     * Maximum possible room level in millibels.
     */
    const int MAX_ROOM_LEVEL_MB = 0;
    /**
     * Room level apply to the reverb effect in millibels.
     */
    int roomLevelMb;

    /**
     * Minimal possible room hf level in millibels.
     */
    const int MIN_ROOM_HF_LEVEL_MB = -4000;
    /**
     * Maximum possible room hf level in millibels.
     */
    const int MAX_ROOM_HF_LEVEL_MB = 0;
    /**
     * Room HF level apply to the reverb effect in millibels.
     */
    int roomHfLevelMb;

    /**
     * Minimal possible decay time in milliseconds.
     */
    const int MIN_DECAY_TIME_MS = 100;
    /**
     * Maximum possible decay time in milliseconds.
     */
    const int MAX_DECAY_TIME_MS = 20000;
    /**
     * Delay time apply to the reverb effect in milliseconds.
     */
    int decayTimeMs;

    /**
     * Minimal possible per mille decay hf ratio.
     */
    const int MIN_DECAY_HF_RATIO_PM = 100;
    /**
     * Maximum possible per mille decay hf ratio.
     */
    const int MAX_DECAY_HF_RATIO_PM = 1000;
    /**
     * HF decay ratio in permilles.
     */
    int decayHfRatioPm;

    /**
     * Minimal possible room level in millibels.
     */
    const int MIN_LEVEL_MB = -6000;
    /**
     * Maximum possible room level in millibels.
     */
    const int MAX_LEVEL_MB = 0;
    /**
     * Reverb level in millibels.
     */
    int levelMb;

    /**
     * Minimal possible delay time in milliseconds.
     */
    const int MIN_DELAY_MS = 0;
    /**
     * Maximum possible delay time in milliseconds.
     */
    const int MAX_DELAY_MS = 65;
    /**
     * Reverb delay in milliseconds.
     */
    int delayMs;

    /**
     * Minimal possible per mille diffusion.
     */
    const int MIN_DIFFUSION_PM = 0;
    /**
     * Maximum possible per mille diffusion.
     */
    const int MAX_DIFFUSION_PM = 1000;
    /**
     * Diffusion in permilles.
     */
    int diffusionPm;

    /**
     * Minimal possible per mille density.
     */
    const int MIN_DENSITY_PM = 0;
    /**
     * Maximum possible per mille density.
     */
    const int MAX_DENSITY_PM = 1000;
    /**
     * Density in permilles.
     */
    int densityPm;

    /**
     * Bypass reverb and copy input to output if set to true.
     */
+5 −130
Original line number Diff line number Diff line
@@ -60,8 +60,7 @@ extern "C" binder_exception_t queryEffect(const AudioUuid* in_impl_uuid, Descrip
namespace aidl::android::hardware::audio::effect {

const std::string EnvReverbSw::kEffectName = "EnvReverbSw";
const EnvironmentalReverb::Capability EnvReverbSw::kCapability = {
        .maxDecayTimeMs = EnvironmentalReverb::MAX_DECAY_TIME_MS};
const EnvironmentalReverb::Capability EnvReverbSw::kCapability;
const Descriptor EnvReverbSw::kDescriptor = {
        .common = {.id = {.type = kEnvReverbTypeUUID,
                          .uuid = kEnvReverbSwImplUUID,
@@ -83,140 +82,16 @@ ndk::ScopedAStatus EnvReverbSw::setParameterSpecific(const Parameter::Specific&
    RETURN_IF(Parameter::Specific::environmentalReverb != specific.getTag(), EX_ILLEGAL_ARGUMENT,
              "EffectNotSupported");

    auto& erParam = specific.get<Parameter::Specific::environmentalReverb>();
    auto tag = erParam.getTag();

    switch (tag) {
        case EnvironmentalReverb::roomLevelMb: {
            RETURN_IF(mContext->setErRoomLevel(erParam.get<EnvironmentalReverb::roomLevelMb>()) !=
                              RetCode::SUCCESS,
                      EX_ILLEGAL_ARGUMENT, "setRoomLevelFailed");
            return ndk::ScopedAStatus::ok();
        }
        case EnvironmentalReverb::roomHfLevelMb: {
            RETURN_IF(
                    mContext->setErRoomHfLevel(erParam.get<EnvironmentalReverb::roomHfLevelMb>()) !=
                            RetCode::SUCCESS,
                    EX_ILLEGAL_ARGUMENT, "setRoomHfLevelFailed");
            return ndk::ScopedAStatus::ok();
        }
        case EnvironmentalReverb::decayTimeMs: {
            RETURN_IF(mContext->setErDecayTime(erParam.get<EnvironmentalReverb::decayTimeMs>()) !=
                              RetCode::SUCCESS,
                      EX_ILLEGAL_ARGUMENT, "setDecayTimeFailed");
            return ndk::ScopedAStatus::ok();
        }
        case EnvironmentalReverb::decayHfRatioPm: {
            RETURN_IF(
                    mContext->setErDecayHfRatio(
                            erParam.get<EnvironmentalReverb::decayHfRatioPm>()) != RetCode::SUCCESS,
                    EX_ILLEGAL_ARGUMENT, "setDecayHfRatioFailed");
            return ndk::ScopedAStatus::ok();
        }
        case EnvironmentalReverb::levelMb: {
            RETURN_IF(mContext->setErLevel(erParam.get<EnvironmentalReverb::levelMb>()) !=
                              RetCode::SUCCESS,
                      EX_ILLEGAL_ARGUMENT, "setLevelFailed");
    mSpecificParam = specific.get<Parameter::Specific::environmentalReverb>();
    LOG(DEBUG) << __func__ << " success with: " << specific.toString();
    return ndk::ScopedAStatus::ok();
}
        case EnvironmentalReverb::delayMs: {
            RETURN_IF(mContext->setErDelay(erParam.get<EnvironmentalReverb::delayMs>()) !=
                              RetCode::SUCCESS,
                      EX_ILLEGAL_ARGUMENT, "setDelayFailed");
            return ndk::ScopedAStatus::ok();
        }
        case EnvironmentalReverb::diffusionPm: {
            RETURN_IF(mContext->setErDiffusion(erParam.get<EnvironmentalReverb::diffusionPm>()) !=
                              RetCode::SUCCESS,
                      EX_ILLEGAL_ARGUMENT, "setDiffusionFailed");
            return ndk::ScopedAStatus::ok();
        }
        case EnvironmentalReverb::densityPm: {
            RETURN_IF(mContext->setErDensity(erParam.get<EnvironmentalReverb::densityPm>()) !=
                              RetCode::SUCCESS,
                      EX_ILLEGAL_ARGUMENT, "setDensityFailed");
            return ndk::ScopedAStatus::ok();
        }
        case EnvironmentalReverb::bypass: {
            RETURN_IF(mContext->setErBypass(erParam.get<EnvironmentalReverb::bypass>()) !=
                              RetCode::SUCCESS,
                      EX_ILLEGAL_ARGUMENT, "setBypassFailed");
            return ndk::ScopedAStatus::ok();
        }
        default: {
            LOG(ERROR) << __func__ << " unsupported tag: " << toString(tag);
            return ndk::ScopedAStatus::fromExceptionCodeWithMessage(
                    EX_ILLEGAL_ARGUMENT, "EnvironmentalReverbTagNotSupported");
        }
    }
}

ndk::ScopedAStatus EnvReverbSw::getParameterSpecific(const Parameter::Id& id,
                                                     Parameter::Specific* specific) {
    auto tag = id.getTag();
    RETURN_IF(Parameter::Id::environmentalReverbTag != tag, EX_ILLEGAL_ARGUMENT, "wrongIdTag");
    auto erId = id.get<Parameter::Id::environmentalReverbTag>();
    auto erIdTag = erId.getTag();
    switch (erIdTag) {
        case EnvironmentalReverb::Id::commonTag:
            return getParameterEnvironmentalReverb(erId.get<EnvironmentalReverb::Id::commonTag>(),
                                                   specific);
        default:
            LOG(ERROR) << __func__ << " unsupported tag: " << toString(erIdTag);
            return ndk::ScopedAStatus::fromExceptionCodeWithMessage(
                    EX_ILLEGAL_ARGUMENT, "EnvironmentalReverbTagNotSupported");
    }
}

ndk::ScopedAStatus EnvReverbSw::getParameterEnvironmentalReverb(const EnvironmentalReverb::Tag& tag,
                                                                Parameter::Specific* specific) {
    RETURN_IF(!mContext, EX_NULL_POINTER, "nullContext");
    EnvironmentalReverb erParam;
    switch (tag) {
        case EnvironmentalReverb::roomLevelMb: {
            erParam.set<EnvironmentalReverb::roomLevelMb>(mContext->getErRoomLevel());
            break;
        }
        case EnvironmentalReverb::roomHfLevelMb: {
            erParam.set<EnvironmentalReverb::roomHfLevelMb>(mContext->getErRoomHfLevel());
            break;
        }
        case EnvironmentalReverb::decayTimeMs: {
            erParam.set<EnvironmentalReverb::decayTimeMs>(mContext->getErDecayTime());
            break;
        }
        case EnvironmentalReverb::decayHfRatioPm: {
            erParam.set<EnvironmentalReverb::decayHfRatioPm>(mContext->getErDecayHfRatio());
            break;
        }
        case EnvironmentalReverb::levelMb: {
            erParam.set<EnvironmentalReverb::levelMb>(mContext->getErLevel());
            break;
        }
        case EnvironmentalReverb::delayMs: {
            erParam.set<EnvironmentalReverb::delayMs>(mContext->getErDelay());
            break;
        }
        case EnvironmentalReverb::diffusionPm: {
            erParam.set<EnvironmentalReverb::diffusionPm>(mContext->getErDiffusion());
            break;
        }
        case EnvironmentalReverb::densityPm: {
            erParam.set<EnvironmentalReverb::densityPm>(mContext->getErDensity());
            break;
        }
        case EnvironmentalReverb::bypass: {
            erParam.set<EnvironmentalReverb::bypass>(mContext->getErBypass());
            break;
        }
        default: {
            LOG(ERROR) << __func__ << " unsupported tag: " << toString(tag);
            return ndk::ScopedAStatus::fromExceptionCodeWithMessage(
                    EX_ILLEGAL_ARGUMENT, "EnvironmentalReverbTagNotSupported");
        }
    }

    specific->set<Parameter::Specific::environmentalReverb>(erParam);
    specific->set<Parameter::Specific::environmentalReverb>(mSpecificParam);
    return ndk::ScopedAStatus::ok();
}

+3 −116
Original line number Diff line number Diff line
@@ -32,120 +32,7 @@ class EnvReverbSwContext final : public EffectContext {
        : EffectContext(statusDepth, common) {
        LOG(DEBUG) << __func__;
    }

    RetCode setErRoomLevel(int roomLevel) {
        if (roomLevel < EnvironmentalReverb::MIN_ROOM_LEVEL_MB ||
            roomLevel > EnvironmentalReverb::MAX_ROOM_LEVEL_MB) {
            LOG(ERROR) << __func__ << " invalid roomLevel: " << roomLevel;
            return RetCode::ERROR_ILLEGAL_PARAMETER;
        }
        // TODO : Add implementation to apply new room level
        mRoomLevel = roomLevel;
        return RetCode::SUCCESS;
    }
    int getErRoomLevel() const { return mRoomLevel; }

    RetCode setErRoomHfLevel(int roomHfLevel) {
        if (roomHfLevel < EnvironmentalReverb::MIN_ROOM_HF_LEVEL_MB ||
            roomHfLevel > EnvironmentalReverb::MAX_ROOM_HF_LEVEL_MB) {
            LOG(ERROR) << __func__ << " invalid roomHfLevel: " << roomHfLevel;
            return RetCode::ERROR_ILLEGAL_PARAMETER;
        }
        // TODO : Add implementation to apply new room HF level
        mRoomHfLevel = roomHfLevel;
        return RetCode::SUCCESS;
    }
    int getErRoomHfLevel() const { return mRoomHfLevel; }

    RetCode setErDecayTime(int decayTime) {
        if (decayTime < EnvironmentalReverb::MIN_DECAY_TIME_MS ||
            decayTime > EnvironmentalReverb::MAX_DECAY_TIME_MS) {
            LOG(ERROR) << __func__ << " invalid decayTime: " << decayTime;
            return RetCode::ERROR_ILLEGAL_PARAMETER;
        }
        // TODO : Add implementation to apply new decay time
        mDecayTime = decayTime;
        return RetCode::SUCCESS;
    }
    int getErDecayTime() const { return mDecayTime; }

    RetCode setErDecayHfRatio(int decayHfRatio) {
        if (decayHfRatio < EnvironmentalReverb::MIN_DECAY_HF_RATIO_PM ||
            decayHfRatio > EnvironmentalReverb::MAX_DECAY_HF_RATIO_PM) {
            LOG(ERROR) << __func__ << " invalid decayHfRatio: " << decayHfRatio;
            return RetCode::ERROR_ILLEGAL_PARAMETER;
        }
        // TODO : Add implementation to apply new decay HF ratio
        mDecayHfRatio = decayHfRatio;
        return RetCode::SUCCESS;
    }
    int getErDecayHfRatio() const { return mDecayHfRatio; }

    RetCode setErLevel(int level) {
        if (level < EnvironmentalReverb::MIN_LEVEL_MB ||
            level > EnvironmentalReverb::MAX_LEVEL_MB) {
            LOG(ERROR) << __func__ << " invalid level: " << level;
            return RetCode::ERROR_ILLEGAL_PARAMETER;
        }
        // TODO : Add implementation to apply new level
        mLevel = level;
        return RetCode::SUCCESS;
    }
    int getErLevel() const { return mLevel; }

    RetCode setErDelay(int delay) {
        if (delay < EnvironmentalReverb::MIN_DELAY_MS ||
            delay > EnvironmentalReverb::MAX_DELAY_MS) {
            LOG(ERROR) << __func__ << " invalid delay: " << delay;
            return RetCode::ERROR_ILLEGAL_PARAMETER;
        }
        // TODO : Add implementation to apply new delay
        mDelay = delay;
        return RetCode::SUCCESS;
    }
    int getErDelay() const { return mDelay; }

    RetCode setErDiffusion(int diffusion) {
        if (diffusion < EnvironmentalReverb::MIN_DIFFUSION_PM ||
            diffusion > EnvironmentalReverb::MAX_DIFFUSION_PM) {
            LOG(ERROR) << __func__ << " invalid diffusion: " << diffusion;
            return RetCode::ERROR_ILLEGAL_PARAMETER;
        }
        // TODO : Add implementation to apply new diffusion
        mDiffusion = diffusion;
        return RetCode::SUCCESS;
    }
    int getErDiffusion() const { return mDiffusion; }

    RetCode setErDensity(int density) {
        if (density < EnvironmentalReverb::MIN_DENSITY_PM ||
            density > EnvironmentalReverb::MAX_DENSITY_PM) {
            LOG(ERROR) << __func__ << " invalid density: " << density;
            return RetCode::ERROR_ILLEGAL_PARAMETER;
        }
        // TODO : Add implementation to apply new density
        mDensity = density;
        return RetCode::SUCCESS;
    }
    int getErDensity() const { return mDensity; }

    RetCode setErBypass(bool bypass) {
        // TODO : Add implementation to apply new bypass
        mBypass = bypass;
        return RetCode::SUCCESS;
    }
    bool getErBypass() const { return mBypass; }

  private:
    int mRoomLevel = EnvironmentalReverb::MIN_ROOM_LEVEL_MB;       // Default room level
    int mRoomHfLevel = EnvironmentalReverb::MAX_ROOM_HF_LEVEL_MB;  // Default room hf level
    int mDecayTime = 1000;                                         // Default decay time
    int mDecayHfRatio = 500;                                       // Default decay hf ratio
    int mLevel = EnvironmentalReverb::MIN_LEVEL_MB;                // Default level
    int mDelay = 40;                                               // Default delay
    int mDiffusion = EnvironmentalReverb::MAX_DIFFUSION_PM;        // Default diffusion
    int mDensity = EnvironmentalReverb::MAX_DENSITY_PM;            // Default density
    bool mBypass = false;                                          // Default bypass
    // TODO: add specific context here
};

class EnvReverbSw final : public EffectImpl {
@@ -173,7 +60,7 @@ class EnvReverbSw final : public EffectImpl {

  private:
    std::shared_ptr<EnvReverbSwContext> mContext;
    ndk::ScopedAStatus getParameterEnvironmentalReverb(const EnvironmentalReverb::Tag& tag,
                                                       Parameter::Specific* specific);
    /* parameters */
    EnvironmentalReverb mSpecificParam;
};
}  // namespace aidl::android::hardware::audio::effect
Loading