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

Commit 032d0d5b authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 11491255 from 53c8336a to 24Q2-release

Change-Id: I331cb96c770dedc5999d6a5a9df5af96e6c92f68
parents 591f1efe 53c8336a
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -441,10 +441,10 @@ void AudioMixer::setParameter(int name, int target, int param, void *value)
                track->prepareForAdjustChannels(mFrameCount);
            }
            } break;
        case HAPTIC_INTENSITY: {
            const os::HapticScale hapticIntensity = static_cast<os::HapticScale>(valueInt);
            if (track->mHapticIntensity != hapticIntensity) {
                track->mHapticIntensity = hapticIntensity;
        case HAPTIC_SCALE: {
            const os::HapticScale hapticScale = *reinterpret_cast<os::HapticScale*>(value);
            if (track->mHapticScale != hapticScale) {
                track->mHapticScale = hapticScale;
            }
            } break;
        case HAPTIC_MAX_AMPLITUDE: {
@@ -585,7 +585,7 @@ status_t AudioMixer::postCreateTrack(TrackBase *track)
    t->mPlaybackRate = AUDIO_PLAYBACK_RATE_DEFAULT;
    // haptic
    t->mHapticPlaybackEnabled = false;
    t->mHapticIntensity = os::HapticScale::NONE;
    t->mHapticScale = {/*level=*/os::HapticLevel::NONE };
    t->mHapticMaxAmplitude = NAN;
    t->mMixerHapticChannelMask = AUDIO_CHANNEL_NONE;
    t->mMixerHapticChannelCount = 0;
@@ -636,7 +636,7 @@ void AudioMixer::postProcess()
                switch (t->mMixerFormat) {
                // Mixer format should be AUDIO_FORMAT_PCM_FLOAT.
                case AUDIO_FORMAT_PCM_FLOAT: {
                    os::scaleHapticData((float*) buffer, sampleCount, t->mHapticIntensity,
                    os::scaleHapticData((float*) buffer, sampleCount, t->mHapticScale,
                                        t->mHapticMaxAmplitude);
                } break;
                default:
+2 −2
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ public:
        DOWNMIX_TYPE    = 0x4004,
        // for haptic
        HAPTIC_ENABLED  = 0x4007, // Set haptic data from this track should be played or not.
        HAPTIC_INTENSITY = 0x4008, // Set the intensity to play haptic data.
        HAPTIC_SCALE = 0x4008, // Set the scale to play haptic data.
        HAPTIC_MAX_AMPLITUDE = 0x4009, // Set the max amplitude allowed for haptic data.
        // for target TIMESTRETCH
        PLAYBACK_RATE   = 0x4300, // Configure timestretch on this track name;
@@ -141,7 +141,7 @@ private:

        // Haptic
        bool                 mHapticPlaybackEnabled;
        os::HapticScale      mHapticIntensity;
        os::HapticScale      mHapticScale;
        float                mHapticMaxAmplitude;
        audio_channel_mask_t mHapticChannelMask;
        uint32_t             mHapticChannelCount;
+8 −6
Original line number Diff line number Diff line
@@ -145,7 +145,7 @@ int HapticGenerator_Init(struct HapticGeneratorContext *context) {
    memset(context->param.hapticChannelSource, 0, sizeof(context->param.hapticChannelSource));
    context->param.hapticChannelCount = 0;
    context->param.audioChannelCount = 0;
    context->param.maxHapticIntensity = os::HapticScale::MUTE;
    context->param.maxHapticIntensity = os::HapticLevel::MUTE;

    context->param.resonantFrequency = DEFAULT_RESONANT_FREQUENCY;
    context->param.bpfQ = 1.0f;
@@ -316,9 +316,10 @@ int HapticGenerator_SetParameter(struct HapticGeneratorContext *context,
            return -EINVAL;
        }
        int id = *(int *) value;
        os::HapticScale hapticIntensity = static_cast<os::HapticScale>(*((int *) value + 1));
        os::HapticLevel hapticIntensity =
                static_cast<os::HapticLevel>(*((int *) value + 1));
        ALOGD("Setting haptic intensity as %d", static_cast<int>(hapticIntensity));
        if (hapticIntensity == os::HapticScale::MUTE) {
        if (hapticIntensity == os::HapticLevel::MUTE) {
            context->param.id2Intensity.erase(id);
        } else {
            context->param.id2Intensity.emplace(id, hapticIntensity);
@@ -478,7 +479,7 @@ int32_t HapticGenerator_Process(effect_handle_t self,
        return -ENODATA;
    }

    if (context->param.maxHapticIntensity == os::HapticScale::MUTE) {
    if (context->param.maxHapticIntensity == os::HapticLevel::MUTE) {
        // Haptic channels are muted, not need to generate haptic data.
        return 0;
    }
@@ -504,7 +505,8 @@ int32_t HapticGenerator_Process(effect_handle_t self,
    float* hapticOutBuffer = HapticGenerator_runProcessingChain(
            context->processingChain, context->inputBuffer.data(),
            context->outputBuffer.data(), inBuffer->frameCount);
    os::scaleHapticData(hapticOutBuffer, hapticSampleCount, context->param.maxHapticIntensity,
        os::scaleHapticData(hapticOutBuffer, hapticSampleCount,
                            { /*level=*/context->param.maxHapticIntensity},
                            context->param.maxHapticAmplitude);

    // For haptic data, the haptic playback thread will copy the data from effect input buffer,
+2 −2
Original line number Diff line number Diff line
@@ -49,8 +49,8 @@ struct HapticGeneratorParam {
    uint32_t hapticChannelCount;

    // A map from track id to haptic intensity.
    std::map<int, os::HapticScale> id2Intensity;
    os::HapticScale maxHapticIntensity; // max intensity will be used to scale haptic data.
    std::map<int, os::HapticLevel> id2Intensity;
    os::HapticLevel maxHapticIntensity; // max intensity will be used to scale haptic data.
    float maxHapticAmplitude; // max amplitude will be used to limit haptic data absolute values.

    float resonantFrequency;
+1 −1
Original line number Diff line number Diff line
@@ -174,7 +174,7 @@ IEffect::Status HapticGeneratorContext::process(float* in, float* out, int sampl
            runProcessingChain(mInputBuffer.data(), mOutputBuffer.data(), mFrameCount);
    ::android::os::scaleHapticData(
            hapticOutBuffer, hapticSampleCount,
            static_cast<::android::os::HapticScale>(mParams.mMaxVibratorScale),
            {/*level=*/static_cast<::android::os::HapticLevel>(mParams.mMaxVibratorScale) },
            mParams.mVibratorInfo.qFactor);

    // For haptic data, the haptic playback thread will copy the data from effect input
Loading