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

Commit 0d02d9f1 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "EnvironmentalReverb : Add minimum and maximum capabilities for params." am: 5616efe8

parents e1a0cd98 5616efe8
Loading
Loading
Loading
Loading
+11 −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;
@@ -68,6 +52,17 @@ union EnvironmentalReverb {
  @VintfStability
  parcelable Capability {
    android.hardware.audio.effect.VendorExtension extension;
    int minRoomLevelMb;
    int maxRoomLevelMb;
    int minRoomHfLevelMb;
    int maxRoomHfLevelMb;
    int maxDecayTimeMs;
    int minDecayHfRatioPm;
    int maxDecayHfRatioPm;
    int minLevelMb;
    int maxLevelMb;
    int maxDelayMs;
    int maxDiffusionPm;
    int maxDensityPm;
  }
}
+63 −79
Original line number Diff line number Diff line
@@ -49,113 +49,97 @@ union EnvironmentalReverb {
    parcelable Capability {
        VendorExtension extension;

        /**
         * Max decay time supported in millisecond.
         */
        int maxDecayTimeMs;
    }

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

        int maxRoomLevelMb;
        /**
         * Minimal possible room hf level in millibels.
         */
    const int MIN_ROOM_HF_LEVEL_MB = -4000;
        int minRoomHfLevelMb;
        /**
         * Maximum possible room hf level in millibels.
         */
    const int MAX_ROOM_HF_LEVEL_MB = 0;
        int maxRoomHfLevelMb;
        /**
     * 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.
         * Max decay time supported in millisecond.
         */
    int decayTimeMs;

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

        int maxDecayHfRatioPm;
        /**
         * Minimal possible room level in millibels.
         */
    const int MIN_LEVEL_MB = -6000;
        int minLevelMb;
        /**
         * Maximum possible room level in millibels.
         */
    const int MAX_LEVEL_MB = 0;
        int maxLevelMb;
        /**
     * Reverb level in millibels.
         * Maximum possible delay time in milliseconds.
         */
    int levelMb;

        int maxDelayMs;
        /**
     * Minimal possible delay time in milliseconds.
         * Maximum possible per mille diffusion.
         */
    const int MIN_DELAY_MS = 0;
        int maxDiffusionPm;
        /**
     * Maximum possible delay time in milliseconds.
         * Maximum possible per mille density.
         */
    const int MAX_DELAY_MS = 65;
        int maxDensityPm;
    }

    /**
     * Reverb delay in milliseconds.
     * Room level apply to the reverb effect in millibels. The value of the roomLevelMb must be in
     * range of the value specified by the 'minRoomLevelMb' capability and the 'maxRoomLevelMb'
     * capability.
     */
    int delayMs;

    int roomLevelMb;
    /**
     * Minimal possible per mille diffusion.
     * Room HF level apply to the reverb effect in millibels. The value of the roomHfLevelMb must be
     * in range of the value specified by the 'minRoomHfLevelMb' capability and the
     * 'maxRoomHfLevelMb' capability.
     */
    const int MIN_DIFFUSION_PM = 0;
    int roomHfLevelMb;
    /**
     * Maximum possible per mille diffusion.
     * Delay time apply to the reverb effect in milliseconds.The value of the decayTimeMs must
     * be non-negative and not exceed the value specified by the 'maxDecayTimeMs' capability.
     */
    const int MAX_DIFFUSION_PM = 1000;
    int decayTimeMs;
    /**
     * Diffusion in permilles.
     * HF decay ratio in permilles. The value of the decayHfRatioPm must be in range
     * of the value specified by the 'minDecayHfRatioPm' capability and the 'maxDecayHfRatioPm'
     * capability.
     */
    int diffusionPm;

    int decayHfRatioPm;
    /**
     * Minimal possible per mille density.
     * Reverb level in millibels. The value of the levelMb must be in range
     * of the value specified by the 'minLevelMb' capability and the 'maxLevelMb' capability.
     */
    const int MIN_DENSITY_PM = 0;
    int levelMb;
    /**
     * Maximum possible per mille density.
     * Reverb delay in milliseconds. The value of the delayMs must be non-negative and not
     * exceed the value specified by the 'maxDelayMs' capability.
     */
    int delayMs;
    /**
     * Diffusion in permilles. The value of the diffusionPm must be non-negative and not
     * exceed the value specified by the 'maxDiffusionPm' capability.
     */
    const int MAX_DENSITY_PM = 1000;
    int diffusionPm;
    /**
     * Density in permilles.
     * Density in permilles. The value of the densityPm must be non-negative and not
     * exceed the value specified by the 'maxDensityPm' capability.
     */
    int densityPm;

+96 −2
Original line number Diff line number Diff line
@@ -60,8 +60,18 @@ 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 = {.minRoomLevelMb = -6000,
                                                                  .maxRoomLevelMb = 0,
                                                                  .minRoomHfLevelMb = -4000,
                                                                  .maxRoomHfLevelMb = 0,
                                                                  .maxDecayTimeMs = 7000,
                                                                  .minDecayHfRatioPm = 100,
                                                                  .maxDecayHfRatioPm = 2000,
                                                                  .minLevelMb = -6000,
                                                                  .maxLevelMb = 0,
                                                                  .maxDelayMs = 65,
                                                                  .maxDiffusionPm = 1000,
                                                                  .maxDensityPm = 1000};
const Descriptor EnvReverbSw::kDescriptor = {
        .common = {.id = {.type = kEnvReverbTypeUUID,
                          .uuid = kEnvReverbSwImplUUID,
@@ -251,4 +261,88 @@ IEffect::Status EnvReverbSw::effectProcessImpl(float* in, float* out, int sample
    return {STATUS_OK, samples, samples};
}

RetCode EnvReverbSwContext::setErRoomLevel(int roomLevel) {
    if (roomLevel < EnvReverbSw::kCapability.minRoomLevelMb ||
        roomLevel > EnvReverbSw::kCapability.maxRoomLevelMb) {
        LOG(ERROR) << __func__ << " invalid roomLevel: " << roomLevel;
        return RetCode::ERROR_ILLEGAL_PARAMETER;
    }
    // TODO : Add implementation to apply new room level
    mRoomLevel = roomLevel;
    return RetCode::SUCCESS;
}

RetCode EnvReverbSwContext::setErRoomHfLevel(int roomHfLevel) {
    if (roomHfLevel < EnvReverbSw::kCapability.minRoomHfLevelMb ||
        roomHfLevel > EnvReverbSw::kCapability.maxRoomHfLevelMb) {
        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;
}

RetCode EnvReverbSwContext::setErDecayTime(int decayTime) {
    if (decayTime < 0 || decayTime > EnvReverbSw::kCapability.maxDecayTimeMs) {
        LOG(ERROR) << __func__ << " invalid decayTime: " << decayTime;
        return RetCode::ERROR_ILLEGAL_PARAMETER;
    }
    // TODO : Add implementation to apply new decay time
    mDecayTime = decayTime;
    return RetCode::SUCCESS;
}

RetCode EnvReverbSwContext::setErDecayHfRatio(int decayHfRatio) {
    if (decayHfRatio < EnvReverbSw::kCapability.minDecayHfRatioPm ||
        decayHfRatio > EnvReverbSw::kCapability.maxDecayHfRatioPm) {
        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;
}

RetCode EnvReverbSwContext::setErLevel(int level) {
    if (level < EnvReverbSw::kCapability.minLevelMb ||
        level > EnvReverbSw::kCapability.maxLevelMb) {
        LOG(ERROR) << __func__ << " invalid level: " << level;
        return RetCode::ERROR_ILLEGAL_PARAMETER;
    }
    // TODO : Add implementation to apply new level
    mLevel = level;
    return RetCode::SUCCESS;
}

RetCode EnvReverbSwContext::setErDelay(int delay) {
    if (delay < 0 || delay > EnvReverbSw::kCapability.maxDelayMs) {
        LOG(ERROR) << __func__ << " invalid delay: " << delay;
        return RetCode::ERROR_ILLEGAL_PARAMETER;
    }
    // TODO : Add implementation to apply new delay
    mDelay = delay;
    return RetCode::SUCCESS;
}

RetCode EnvReverbSwContext::setErDiffusion(int diffusion) {
    if (diffusion < 0 || diffusion > EnvReverbSw::kCapability.maxDiffusionPm) {
        LOG(ERROR) << __func__ << " invalid diffusion: " << diffusion;
        return RetCode::ERROR_ILLEGAL_PARAMETER;
    }
    // TODO : Add implementation to apply new diffusion
    mDiffusion = diffusion;
    return RetCode::SUCCESS;
}

RetCode EnvReverbSwContext::setErDensity(int density) {
    if (density < 0 || density > EnvReverbSw::kCapability.maxDensityPm) {
        LOG(ERROR) << __func__ << " invalid density: " << density;
        return RetCode::ERROR_ILLEGAL_PARAMETER;
    }
    // TODO : Add implementation to apply new density
    mDensity = density;
    return RetCode::SUCCESS;
}

}  // namespace aidl::android::hardware::audio::effect
+13 −85
Original line number Diff line number Diff line
@@ -33,100 +33,28 @@ class EnvReverbSwContext final : public EffectContext {
        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;
    }
    RetCode setErRoomLevel(int roomLevel);
    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;
    }
    RetCode setErRoomHfLevel(int roomHfLevel);
    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;
    }
    RetCode setErDecayTime(int decayTime);
    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;
    }
    RetCode setErDecayHfRatio(int decayHfRatio);
    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;
    }
    RetCode setErLevel(int level);
    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;
    }
    RetCode setErDelay(int delay);
    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;
    }
    RetCode setErDiffusion(int diffusion);
    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;
    }
    RetCode setErDensity(int density);
    int getErDensity() const { return mDensity; }

    RetCode setErBypass(bool bypass) {
@@ -137,14 +65,14 @@ class EnvReverbSwContext final : public EffectContext {
    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 mRoomLevel = -6000;                                        // Default room level
    int mRoomHfLevel = 0;                                          // 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 mLevel = -6000;                                            // Default level
    int mDelay = 40;                                               // Default delay
    int mDiffusion = EnvironmentalReverb::MAX_DIFFUSION_PM;        // Default diffusion
    int mDensity = EnvironmentalReverb::MAX_DENSITY_PM;            // Default density
    int mDiffusion = 1000;                                         // Default diffusion
    int mDensity = 1000;                                           // Default density
    bool mBypass = false;                                          // Default bypass
};

+192 −70

File changed.

Preview size limit exceeded, changes collapsed.