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

Commit 6e6aa21e authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 12205827 from 1cce4817 to 24Q4-release

Change-Id: Idc685cd7cf7351deb79e160411fd9e51322f7d2b
parents 65e7f20c 1cce4817
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -267,3 +267,13 @@ flag {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    namespace: "camera_platform"
    name: "dumpsys_request_stream_ids"
    description: "Add stream id information to last request dumpsys"
    bug: "357913929"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}
 No newline at end of file
+6 −4
Original line number Diff line number Diff line
@@ -2401,12 +2401,14 @@ nsecs_t AudioTrack::processAudioBuffer()
    int32_t flags = android_atomic_and(
        ~(CBLK_UNDERRUN | CBLK_LOOP_CYCLE | CBLK_LOOP_FINAL | CBLK_BUFFER_END), &mCblk->mFlags);

    const bool isOffloaded = isOffloaded_l();
    const bool isOffloadedOrDirect = isOffloadedOrDirect_l();
    // Check for track invalidation
    if (flags & CBLK_INVALID) {
        // for offloaded tracks restoreTrack_l() will just update the sequence and clear
        // AudioSystem cache. We should not exit here but after calling the callback so
        // that the upper layers can recreate the track
        if (!isOffloadedOrDirect_l() || (mSequence == mObservedSequence)) {
        if (!isOffloadedOrDirect || (mSequence == mObservedSequence)) {
            status_t status __unused = restoreTrack_l("processAudioBuffer");
            // FIXME unused status
            // after restoration, continue below to make sure that the loop and buffer events
@@ -2576,7 +2578,7 @@ nsecs_t AudioTrack::processAudioBuffer()
        mObservedSequence = sequence;
        callback->onNewIAudioTrack();
        // for offloaded tracks, just wait for the upper layers to recreate the track
        if (isOffloadedOrDirect()) {
        if (isOffloadedOrDirect) {
            return NS_INACTIVE;
        }
    }
@@ -2664,7 +2666,7 @@ nsecs_t AudioTrack::processAudioBuffer()
                __func__, mPortId, mRemainingFrames, avail, audioBuffer.frameCount, nonContig, err);
        if (err != NO_ERROR) {
            if (err == TIMED_OUT || err == WOULD_BLOCK || err == -EINTR ||
                    (isOffloaded() && (err == DEAD_OBJECT))) {
                    (isOffloaded && (err == DEAD_OBJECT))) {
                // FIXME bug 25195759
                return 1000000;
            }
@@ -2750,7 +2752,7 @@ nsecs_t AudioTrack::processAudioBuffer()
            // buffer size and skip the loop entirely.

            nsecs_t myns;
            if (audio_has_proportional_frames(mFormat)) {
            if (!isOffloaded && audio_has_proportional_frames(mFormat)) {
                // time to wait based on buffer occupancy
                const nsecs_t datans = mRemainingFrames <= avail ? 0 :
                        framesToNanoseconds(mRemainingFrames - avail, sampleRate, speed);
+1 −1
Original line number Diff line number Diff line
@@ -585,7 +585,7 @@ status_t AudioMixer::postCreateTrack(TrackBase *track)
    t->mPlaybackRate = AUDIO_PLAYBACK_RATE_DEFAULT;
    // haptic
    t->mHapticPlaybackEnabled = false;
    t->mHapticScale = {/*level=*/os::HapticLevel::NONE };
    t->mHapticScale = os::HapticScale::none();
    t->mHapticMaxAmplitude = NAN;
    t->mMixerHapticChannelMask = AUDIO_CHANNEL_NONE;
    t->mMixerHapticChannelCount = 0;
+35 −21
Original line number Diff line number Diff line
@@ -35,12 +35,15 @@
#include <audio_utils/format.h>
#include <audio_utils/safe_math.h>
#include <system/audio.h>
#include <system/audio_effects/audio_effects_utils.h>

static constexpr float DEFAULT_RESONANT_FREQUENCY = 150.0f;
static constexpr float DEFAULT_BSF_ZERO_Q = 8.0f;
static constexpr float DEFAULT_BSF_POLE_Q = 4.0f;
static constexpr float DEFAULT_DISTORTION_OUTPUT_GAIN = 1.5f;

using android::effect::utils::EffectParamReader;

// This is the only symbol that needs to be exported
__attribute__ ((visibility ("default")))
audio_effect_library_t AUDIO_EFFECT_LIBRARY_INFO_SYM = {
@@ -307,25 +310,32 @@ int HapticGenerator_Reset(struct HapticGeneratorContext *context) {
    return 0;
}

int HapticGenerator_SetParameter(struct HapticGeneratorContext *context,
                                 int32_t param,
                                 uint32_t size,
                                 void *value) {
    switch (param) {
int HapticGenerator_SetParameter(struct HapticGeneratorContext *context, effect_param_t* param) {
    if (param == nullptr) {
        ALOGE("%s invalid effect_param_t is nullptr", __func__);
        return -EINVAL;
    }
    int32_t paramType;
    EffectParamReader reader(*param);
    reader.readFromParameter(&paramType);

    switch (paramType) {
    case HG_PARAM_HAPTIC_INTENSITY: {
        if (value == nullptr || size != (uint32_t) (2 * sizeof(int) + sizeof(float))) {
        if (param->vsize != (sizeof(int32_t) + sizeof(os::HapticScale))) {
            ALOGE("%s invalid haptic intensity param size %s", __func__, reader.toString().c_str());
            return -EINVAL;
        }
        const int id = *(int *) value;
        const os::HapticLevel hapticLevel = static_cast<os::HapticLevel>(*((int *) value + 1));
        const float adaptiveScaleFactor = (*((float *) value + 2));
        const os::HapticScale hapticScale = {hapticLevel, adaptiveScaleFactor};
        ALOGD("Updating haptic scale, hapticLevel=%d, adaptiveScaleFactor=%f",
              static_cast<int>(hapticLevel), adaptiveScaleFactor);
        int32_t paramId;
        os::HapticScale hapticScale;
        if (reader.readFromValue(&paramId) != OK || reader.readFromValue(&hapticScale) != OK) {
            ALOGE("%s error reading haptic intensity %s", __func__, reader.toString().c_str());
            return -EINVAL;
        }
        ALOGD("Updating haptic scale, %s", hapticScale.toString().c_str());
        if (hapticScale.isScaleMute()) {
            context->param.id2HapticScale.erase(id);
            context->param.id2HapticScale.erase(paramId);
        } else {
            context->param.id2HapticScale.emplace(id, hapticScale);
            context->param.id2HapticScale.emplace(paramId, hapticScale);
        }
        context->param.maxHapticScale = hapticScale;
        for (const auto&[id, scale] : context->param.id2HapticScale) {
@@ -336,12 +346,17 @@ int HapticGenerator_SetParameter(struct HapticGeneratorContext *context,
        break;
    }
    case HG_PARAM_VIBRATOR_INFO: {
        if (value == nullptr || size != 3 * sizeof(float)) {
        if (param->vsize != (3 * sizeof(float))) {
            ALOGE("%s invalid vibrator info param size %s", __func__, reader.toString().c_str());
            return -EINVAL;
        }
        float resonantFrequency, qFactor, maxAmplitude;
        if (reader.readFromValue(&resonantFrequency) != OK ||
            reader.readFromValue(&qFactor) != OK ||
            reader.readFromValue(&maxAmplitude) != OK) {
            ALOGE("%s error reading vibrator info %s", __func__, reader.toString().c_str());
            return -EINVAL;
        }
        const float resonantFrequency = *(float*) value;
        const float qFactor = *((float *) value + 1);
        const float maxAmplitude = *((float *) value + 2);
        context->param.resonantFrequency =
                audio_utils::safe_isnan(resonantFrequency) ? DEFAULT_RESONANT_FREQUENCY
                                                           : resonantFrequency;
@@ -369,7 +384,7 @@ int HapticGenerator_SetParameter(struct HapticGeneratorContext *context,
        HapticGenerator_Reset(context);
    } break;
    default:
        ALOGW("Unknown param: %d", param);
        ALOGW("Unknown param: %d", paramType);
        return -EINVAL;
    }

@@ -573,8 +588,7 @@ int32_t HapticGenerator_Command(effect_handle_t self, uint32_t cmdCode, uint32_t
                return -EINVAL;
            }
            effect_param_t *cmd = (effect_param_t *) cmdData;
            *(int *) replyData = HapticGenerator_SetParameter(
                    context, *(int32_t *) cmd->data, cmd->vsize, cmd->data + sizeof(int32_t));
            *(int *) replyData = HapticGenerator_SetParameter(context, cmd);
        }
            break;

+3 −1
Original line number Diff line number Diff line
@@ -177,7 +177,9 @@ 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::HapticLevel>(mParams.mMaxVibratorScale)} /* scale */,
            // TODO(b/356406686): add the new HapticScale fields to the AIDL interface.
            ::android::os::HapticScale(
                    static_cast<::android::os::HapticLevel>(mParams.mMaxVibratorScale)),
            mParams.mVibratorInfo.maxAmplitude /* limit */);

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