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

Commit f11041b0 authored by Shunkai Yao's avatar Shunkai Yao
Browse files

AIDL hapticgenerator: Update fast-math cflags

Ensure infinities and nan are honored for both HIDL and AIDL
hapticgenerator effect by add honor-infinities and honor-nans to
hapticgeneratordefaults

Test: m
Test: atest --test-mapping hardware/interfaces/audio/aidl/vts:presubmit
Bug: 339319151
Change-Id: Ia1929f4a3c4a717733f2016816b5a784ba31e018
parent 7b9d4bb4
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -37,6 +37,14 @@ cc_defaults {
    header_libs: [
        "libaudioeffects",
    ],
    cflags: [
        // This is needed for the non-zero coefficients optimization for
        // BiquadFilter. Try the biquad_filter_benchmark test in audio_utils
        // with/without `-ffast-math` for more context.
        "-ffast-math",
        "-fhonor-infinities",
        "-fhonor-nans",
    ],
    relative_install_path: "soundfx",
}

@@ -59,12 +67,6 @@ cc_library_shared {
        "-O2",
        "-Wall",
        "-Werror",
        // This is needed for the non-zero coefficients optimization for
        // BiquadFilter. Try the biquad_filter_benchmark test in audio_utils
        // with/without `-ffast-math` for more context.
        "-ffast-math",
        "-fhonor-infinities",
        "-fhonor-nans",
        "-fvisibility=hidden",
    ],
}
+13 −3
Original line number Diff line number Diff line
@@ -14,16 +14,17 @@
 * limitations under the License.
 */

#include <cstddef>
#define LOG_TAG "AHAL_HapticGeneratorContext"

#include <Utils.h>
#include "HapticGeneratorContext.h"
#include <android-base/logging.h>
#include <android-base/parsedouble.h>
#include <android-base/properties.h>
#include <audio_utils/primitives.h>
#include <audio_utils/safe_math.h>
#include <Utils.h>

#include "HapticGeneratorContext.h"
#include <cstddef>

using aidl::android::hardware::audio::common::getChannelCount;
using aidl::android::hardware::audio::common::getPcmSampleSizeInBytes;
@@ -110,6 +111,15 @@ std::vector<HapticGenerator::HapticScale> HapticGeneratorContext::getHgHapticSca
RetCode HapticGeneratorContext::setHgVibratorInformation(
        const HapticGenerator::VibratorInformation& vibratorInfo) {
    mParams.mVibratorInfo = vibratorInfo;
    if (::android::audio_utils::safe_isnan(mParams.mVibratorInfo.resonantFrequencyHz)) {
        LOG(WARNING) << __func__ << " resonantFrequencyHz reset from nan to "
                     << DEFAULT_RESONANT_FREQUENCY;
        mParams.mVibratorInfo.resonantFrequencyHz = DEFAULT_RESONANT_FREQUENCY;
    }
    if (::android::audio_utils::safe_isnan(mParams.mVibratorInfo.qFactor)) {
        LOG(WARNING) << __func__ << " qFactor reset from nan to " << DEFAULT_BSF_ZERO_Q;
        mParams.mVibratorInfo.qFactor = DEFAULT_BSF_ZERO_Q;
    }

    if (mProcessorsRecord.bpf != nullptr) {
        mProcessorsRecord.bpf->setCoefficients(::android::audio_effect::haptic_generator::bpfCoefs(
+5 −3
Original line number Diff line number Diff line
@@ -16,11 +16,13 @@

#pragma once

#include "effect-impl/EffectContext.h"
#include "Processors.h"

#include <vibrator/ExternalVibrationUtils.h>
#include <map>

#include "Processors.h"
#include "effect-impl/EffectContext.h"
#include <cstddef>
#include <map>

namespace aidl::android::hardware::audio::effect {