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

Commit 23d96c30 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 9014491 from 40b989aa to tm-qpr1-release

Change-Id: I13b0b2c99adebe52dff6a1daa765f88abbe1e4cc
parents 55d4112e 40b989aa
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -88,10 +88,12 @@ class HeadTrackingProcessorImpl : public HeadTrackingProcessor {
    }

    void calculate(int64_t timestamp) override {
        // Handle the screen first, since it might trigger a recentering of the head.
        bool screenStable = true;

        // Handle the screen first, since it might: trigger a recentering of the head.
        if (mWorldToScreenTimestamp.has_value()) {
            const Pose3f worldToLogicalScreen = mScreenPoseBias.getOutput();
            bool screenStable = mScreenStillnessDetector.calculate(timestamp);
            screenStable = mScreenStillnessDetector.calculate(timestamp);
            mModeSelector.setScreenStable(mWorldToScreenTimestamp.value(), screenStable);
            // Whenever the screen is unstable, recenter the head pose.
            if (!screenStable) {
@@ -105,7 +107,8 @@ class HeadTrackingProcessorImpl : public HeadTrackingProcessor {
        if (mWorldToHeadTimestamp.has_value()) {
            Pose3f worldToHead = mHeadPoseBias.getOutput();
            // Auto-recenter.
            if (mHeadStillnessDetector.calculate(timestamp)) {
            bool headStable = mHeadStillnessDetector.calculate(timestamp);
            if (headStable || !screenStable) {
                recenter(true, false);
                worldToHead = mHeadPoseBias.getOutput();
            }
+18 −5
Original line number Diff line number Diff line
@@ -26,6 +26,9 @@ void StillnessDetector::reset() {
    mFifo.clear();
    mWindowFull = false;
    mSuppressionDeadline.reset();
    // A "true" state indicates stillness is detected (default = true)
    mCurrentState = true;
    mPreviousState = true;
}

void StillnessDetector::setInput(int64_t timestamp, const Pose3f& input) {
@@ -33,7 +36,15 @@ void StillnessDetector::setInput(int64_t timestamp, const Pose3f& input) {
    discardOld(timestamp);
}

bool StillnessDetector::getPreviousState() const {
    return mPreviousState;
}

bool StillnessDetector::calculate(int64_t timestamp) {
    // Move the current stillness state to the previous state.
    // This allows us to detect transitions into and out of stillness.
    mPreviousState = mCurrentState;

    discardOld(timestamp);

    // Check whether all the poses in the queue are in the proximity of the new one. We want to do
@@ -60,15 +71,17 @@ bool StillnessDetector::calculate(int64_t timestamp) {

    // If the window has not been full, return the default value.
    if (!mWindowFull) {
        return mOptions.defaultValue;
        mCurrentState = mOptions.defaultValue;
    }

    // Force "in motion" while the suppression deadline is active.
    if (mSuppressionDeadline.has_value()) {
        return false;
    else if (mSuppressionDeadline.has_value()) {
        mCurrentState = false;
    }
    else {
        mCurrentState = !moved;
    }

    return !moved;
    return mCurrentState;
}

void StillnessDetector::discardOld(int64_t timestamp) {
+4 −1
Original line number Diff line number Diff line
@@ -80,7 +80,8 @@ class StillnessDetector {
    void setInput(int64_t timestamp, const Pose3f& input);
    /** Calculate whether the stream is still at the given timestamp. */
    bool calculate(int64_t timestamp);

    /** Return the stillness state from the previous call to calculate() */
    bool getPreviousState() const;
  private:
    struct TimestampedPose {
        int64_t timestamp;
@@ -92,6 +93,8 @@ class StillnessDetector {
    const float mCosHalfRotationalThreshold;
    std::deque<TimestampedPose> mFifo;
    bool mWindowFull = false;
    bool mCurrentState = true;
    bool mPreviousState = true;
    // As soon as motion is detected, this will be set for the time of detection + window duration,
    // and during this time we will always consider outselves in motion without checking. This is
    // used for hyteresis purposes, since because of the approximate method we use for determining
+2 −1
Original line number Diff line number Diff line
@@ -516,7 +516,8 @@ void AudioPolicyService::onCheckSpatializer_l()

void AudioPolicyService::doOnCheckSpatializer()
{
    ALOGI("%s mSpatializer %p level %d", __func__, mSpatializer.get(), (int)mSpatializer->getLevel());
    ALOGV("%s mSpatializer %p level %d",
        __func__, mSpatializer.get(), (int)mSpatializer->getLevel());

    if (mSpatializer != nullptr) {
        // Note: mSpatializer != nullptr =>  mAudioPolicyManager != nullptr
+20 −4
Original line number Diff line number Diff line
@@ -59,11 +59,13 @@ using namespace std::chrono_literals;
       if (!_tmp.ok()) return aidl_utils::binderStatusFromStatusT(_tmp.error()); \
       std::move(_tmp.value()); })

audio_channel_mask_t getMaxChannelMask(std::vector<audio_channel_mask_t> masks) {
static audio_channel_mask_t getMaxChannelMask(
        const std::vector<audio_channel_mask_t>& masks, size_t channelLimit = SIZE_MAX) {
    uint32_t maxCount = 0;
    audio_channel_mask_t maxMask = AUDIO_CHANNEL_NONE;
    for (auto mask : masks) {
        const size_t count = audio_channel_count_from_out_mask(mask);
        if (count > channelLimit) continue;  // ignore masks greater than channelLimit
        if (count > maxCount) {
            maxMask = mask;
            maxCount = count;
@@ -238,10 +240,13 @@ sp<Spatializer> Spatializer::create(SpatializerPolicyCallback *callback) {
        spatializer = new Spatializer(descriptors[0], callback);
        if (spatializer->loadEngineConfiguration(effect) != NO_ERROR) {
            spatializer.clear();
        }
            ALOGW("%s loadEngine error: %d  effect Id %" PRId64,
                    __func__, status, effect ? effect->effectId() : 0);
        } else {
            spatializer->mLocalLog.log("%s with effect Id %" PRId64, __func__,
                                       effect ? effect->effectId() : 0);
        }
    }

    return spatializer;
}
@@ -387,7 +392,7 @@ audio_config_base_t Spatializer::getAudioInConfig() const {
    std::lock_guard lock(mLock);
    audio_config_base_t config = AUDIO_CONFIG_BASE_INITIALIZER;
    // For now use highest supported channel count
    config.channel_mask = getMaxChannelMask(mChannelMasks);
    config.channel_mask = getMaxChannelMask(mChannelMasks, FCC_LIMIT);
    return config;
}

@@ -398,6 +403,17 @@ status_t Spatializer::registerCallback(
        return BAD_VALUE;
    }

    if (mSpatializerCallback != nullptr) {
        if (IInterface::asBinder(callback) == IInterface::asBinder(mSpatializerCallback)) {
            ALOGW("%s: Registering callback %p again",
                __func__, mSpatializerCallback.get());
            return NO_ERROR;
        }
        ALOGE("%s: Already one client registered with callback %p",
            __func__, mSpatializerCallback.get());
        return INVALID_OPERATION;
    }

    sp<IBinder> binder = IInterface::asBinder(callback);
    status_t status = binder->linkToDeath(this);
    if (status == NO_ERROR) {
Loading