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

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

Snap for 7752790 from f7249f81 to sc-v2-release

Change-Id: I44b52c965c117d1a8ba893b152152ca0e031e03a
parents e680973b f7249f81
Loading
Loading
Loading
Loading
+23 −1
Original line number Diff line number Diff line
@@ -50,9 +50,15 @@ interface ISpatializer {
    /** Gets the selected spatialization level (see SpatializationLevel.aidl) */
    SpatializationLevel getLevel();

    /** Reports if the spatializer engine supports head tracking or not.
     * This is a pre condition independent of the fact that a head tracking sensor is
     * registered or not.
     */
    boolean isHeadTrackingSupported();

    /** Reports the list of supported head tracking modes (see SpatializerHeadTrackingMode.aidl).
     * The list can be empty if the spatializer implementation does not support head tracking or if
     * no head tracking device is connected.
     * no head tracking sensor is registered (see setHeadSensor() and setScreenSensor()).
     */
    SpatializerHeadTrackingMode[] getSupportedHeadTrackingModes();

@@ -113,4 +119,20 @@ interface ISpatializer {
     */
    void registerHeadTrackingCallback(@nullable ISpatializerHeadTrackingCallback callback);

    /**
     * Sets a parameter to the spatializer engine. Used by effect implementor for vendor
     * specific configuration.
     */
     void setParameter(int key, in byte[] value);

    /**
     * Gets a parameter from the spatializer engine. Used by effect implementor for vendor
     * specific configuration.
     */
     void getParameter(int key, inout byte[] value);

    /**
     * Gets the io handle of the output stream the spatializer is connected to.
     */
     int getOutput();
}
+5 −1
Original line number Diff line number Diff line
@@ -328,7 +328,9 @@ void stereoVolumeHelperWithChannelMask(TO*& out, const TI*& in, const TV *vol, F
    DO_CHANNEL_POSITION(21);
    DO_CHANNEL_POSITION(22);
    DO_CHANNEL_POSITION(23);
    static_assert(FCC_LIMIT <= FCC_24); // Note: this may need to change.
    DO_CHANNEL_POSITION(24);
    DO_CHANNEL_POSITION(25);
    static_assert(FCC_LIMIT <= FCC_26); // Note: this may need to change.
#pragma pop_macro("DO_CHANNEL_POSITION")
}

@@ -346,6 +348,8 @@ constexpr inline audio_channel_mask_t canonicalChannelMaskFromCount(size_t chann
        [7] = AUDIO_CHANNEL_OUT_6POINT1,
        [8] = AUDIO_CHANNEL_OUT_7POINT1,
        [12] = AUDIO_CHANNEL_OUT_7POINT1POINT4,
        [14] = AUDIO_CHANNEL_OUT_9POINT1POINT4,
        [16] = AUDIO_CHANNEL_OUT_9POINT1POINT6,
        [24] = AUDIO_CHANNEL_OUT_22POINT2,
    };
    return channelCount < std::size(canonical) ? canonical[channelCount] : AUDIO_CHANNEL_NONE;
+50 −6
Original line number Diff line number Diff line
@@ -58,12 +58,6 @@ using namespace std::chrono_literals;
       if (!_tmp.ok()) return aidl_utils::binderStatusFromStatusT(_tmp.error()); \
       std::move(_tmp.value()); })

#define RETURN_IF_BINDER_ERROR(x)      \
    {                                  \
        binder::Status _tmp = (x);     \
        if (!_tmp.isOk()) return _tmp; \
    }

// ---------------------------------------------------------------------------

class Spatializer::EngineCallbackHandler : public AHandler {
@@ -332,6 +326,16 @@ Status Spatializer::getLevel(SpatializationLevel *level) {
    return Status::ok();
}

Status Spatializer::isHeadTrackingSupported(bool *supports) {
    ALOGV("%s mSupportsHeadTracking %d", __func__, mSupportsHeadTracking);
    if (supports == nullptr) {
        return binderStatusFromStatusT(BAD_VALUE);
    }
    std::lock_guard lock(mLock);
    *supports = mSupportsHeadTracking;
    return Status::ok();
}

Status Spatializer::getSupportedHeadTrackingModes(
        std::vector<SpatializerHeadTrackingMode>* modes) {
    std::lock_guard lock(mLock);
@@ -485,6 +489,10 @@ Status Spatializer::setDisplayOrientation(float physicalToLogicalAngle) {
    if (mPoseController != nullptr) {
        mPoseController->setDisplayOrientation(mDisplayOrientation);
    }
    if (mEngine != nullptr) {
        setEffectParameter_l(
            SPATIALIZER_PARAM_DISPLAY_ORIENTATION, std::vector<float>{physicalToLogicalAngle});
    }
    return Status::ok();
}

@@ -517,6 +525,42 @@ Status Spatializer::registerHeadTrackingCallback(
    return Status::ok();
}

Status Spatializer::setParameter(int key, const std::vector<unsigned char>& value) {
    ALOGV("%s key %d", __func__, key);
    std::lock_guard lock(mLock);
    status_t status = INVALID_OPERATION;
    if (mEngine != nullptr) {
        status = setEffectParameter_l(key, value);
    }
    return binderStatusFromStatusT(status);
}

Status Spatializer::getParameter(int key, std::vector<unsigned char> *value) {
    ALOGV("%s key %d value size %d", __func__, key,
          (value != nullptr ? (int)value->size() : -1));
    if (value == nullptr) {
        binderStatusFromStatusT(BAD_VALUE);
    }
    std::lock_guard lock(mLock);
    status_t status = INVALID_OPERATION;
    if (mEngine != nullptr) {
        ALOGV("%s key %d mEngine %p", __func__, key, mEngine.get());
        status = getEffectParameter_l(key, value);
    }
    return binderStatusFromStatusT(status);
}

Status Spatializer::getOutput(int *output) {
    ALOGV("%s", __func__);
    if (output == nullptr) {
        binderStatusFromStatusT(BAD_VALUE);
    }
    std::lock_guard lock(mLock);
    *output = VALUE_OR_RETURN_BINDER_STATUS(legacy2aidl_audio_io_handle_t_int32_t(mOutput));
    ALOGV("%s got output %d", __func__, *output);
    return Status::ok();
}

// SpatializerPoseController::Listener
void Spatializer::onHeadToStagePose(const Pose3f& headToStage) {
    ALOGV("%s", __func__);
+45 −1
Original line number Diff line number Diff line
@@ -100,6 +100,7 @@ class Spatializer : public media::BnSpatializer,
    binder::Status getSupportedLevels(std::vector<media::SpatializationLevel>* levels) override;
    binder::Status setLevel(media::SpatializationLevel level) override;
    binder::Status getLevel(media::SpatializationLevel *level) override;
    binder::Status isHeadTrackingSupported(bool *supports);
    binder::Status getSupportedHeadTrackingModes(
            std::vector<media::SpatializerHeadTrackingMode>* modes) override;
    binder::Status setDesiredHeadTrackingMode(
@@ -115,6 +116,9 @@ class Spatializer : public media::BnSpatializer,
    binder::Status getSupportedModes(std::vector<media::SpatializationMode>* modes) override;
    binder::Status registerHeadTrackingCallback(
        const sp<media::ISpatializerHeadTrackingCallback>& callback) override;
    binder::Status setParameter(int key, const std::vector<unsigned char>& value) override;
    binder::Status getParameter(int key, std::vector<unsigned char> *value) override;
    binder::Status getOutput(int *output);

    /** IBinder::DeathRecipient. Listen to the death of the INativeSpatializerCallback. */
    virtual void binderDied(const wp<IBinder>& who);
@@ -209,6 +213,7 @@ private:
        if (numParams > kMaxEffectParamValues) {
            return BAD_VALUE;
        }
        (*values).clear();
        std::copy(&params[0], &params[numParams], back_inserter(*values));
        return NO_ERROR;
    }
@@ -229,7 +234,46 @@ private:
        *(uint32_t *)p->data = type;
        memcpy((uint32_t *)p->data + 1, values.data(), sizeof(T) * values.size());

        return mEngine->setParameter(p);
        status_t status = mEngine->setParameter(p);
        if (status != NO_ERROR) {
            return status;
        }
        if (p->status != NO_ERROR) {
            return p->status;
        }
        return NO_ERROR;
    }

    /**
     * Get a parameter from spatializer engine by calling getParameter on AudioEffect object.
     * It is possible to read more than one value of type T according to the parameter type
     * by specifying values vector size.
     */
    template<typename T>
    status_t getEffectParameter_l(uint32_t type, std::vector<T> *values) REQUIRES(mLock) {
        static_assert(sizeof(T) <= sizeof(uint32_t), "The size of T must less than 32 bits");

        uint32_t cmd[sizeof(effect_param_t) / sizeof(uint32_t) + 1 + values->size()];
        effect_param_t *p = (effect_param_t *)cmd;
        p->psize = sizeof(uint32_t);
        p->vsize = sizeof(T) * values->size();
        *(uint32_t *)p->data = type;

        status_t status = mEngine->getParameter(p);

        if (status != NO_ERROR) {
            return status;
        }
        if (p->status != NO_ERROR) {
            return p->status;
        }

        int numValues = std::min(p->vsize / sizeof(T), values->size());
        (*values).clear();
        T *retValues = (T *)((uint8_t *)p->data + sizeof(uint32_t));
        std::copy(&retValues[0], &retValues[numValues], back_inserter(*values));

        return NO_ERROR;
    }

    void postFramesProcessedMsg(int frames);