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

Commit 5224677e authored by Eric Laurent's avatar Eric Laurent Committed by Automerger Merge Worker
Browse files

Spatializer: add output changed method on native callback am: 4a872860 am: 84440724

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/av/+/16032597

Change-Id: I34fecc217ed14559aa9d89b6bdca273e382870f7
parents ce167b5a 84440724
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -31,4 +31,9 @@ oneway interface INativeSpatializerCallback {
     * (e.g. when the spatializer is enabled or disabled)
     * (e.g. when the spatializer is enabled or disabled)
     */
     */
    void onLevelChanged(SpatializationLevel level);
    void onLevelChanged(SpatializationLevel level);

    /** Called when the output stream the Spatializer is attached to changes.
     * Indicates the IO Handle of the new output.
     */
    void onOutputChanged(int output);
}
}
+31 −11
Original line number Original line Diff line number Diff line
@@ -627,6 +627,9 @@ void Spatializer::onActualModeChangeMsg(HeadTrackingMode mode) {


status_t Spatializer::attachOutput(audio_io_handle_t output) {
status_t Spatializer::attachOutput(audio_io_handle_t output) {
    std::shared_ptr<SpatializerPoseController> poseController;
    std::shared_ptr<SpatializerPoseController> poseController;
    bool outputChanged = false;
    sp<media::INativeSpatializerCallback> callback;

    {
    {
        std::lock_guard lock(mLock);
        std::lock_guard lock(mLock);
        ALOGV("%s output %d mOutput %d", __func__, (int)output, (int)mOutput);
        ALOGV("%s output %d mOutput %d", __func__, (int)output, (int)mOutput);
@@ -654,6 +657,7 @@ status_t Spatializer::attachOutput(audio_io_handle_t output) {
                             std::vector<SpatializerHeadTrackingMode>{mActualHeadTrackingMode});
                             std::vector<SpatializerHeadTrackingMode>{mActualHeadTrackingMode});


        mEngine->setEnabled(true);
        mEngine->setEnabled(true);
        outputChanged = mOutput != output;
        mOutput = output;
        mOutput = output;


        if (mSupportsHeadTracking) {
        if (mSupportsHeadTracking) {
@@ -668,17 +672,26 @@ status_t Spatializer::attachOutput(audio_io_handle_t output) {
            mPoseController->setDisplayOrientation(mDisplayOrientation);
            mPoseController->setDisplayOrientation(mDisplayOrientation);
            poseController = mPoseController;
            poseController = mPoseController;
        }
        }
        callback = mSpatializerCallback;
    }
    }
    if (poseController != nullptr) {
    if (poseController != nullptr) {
        poseController->waitUntilCalculated();
        poseController->waitUntilCalculated();
    }
    }

    if (outputChanged && callback != nullptr) {
        callback->onOutputChanged(output);
    }

    return NO_ERROR;
    return NO_ERROR;
}
}


audio_io_handle_t Spatializer::detachOutput() {
audio_io_handle_t Spatializer::detachOutput() {
    audio_io_handle_t output = AUDIO_IO_HANDLE_NONE;
    sp<media::INativeSpatializerCallback> callback;

    {
        std::lock_guard lock(mLock);
        std::lock_guard lock(mLock);
        ALOGV("%s mOutput %d", __func__, (int)mOutput);
        ALOGV("%s mOutput %d", __func__, (int)mOutput);
    audio_io_handle_t output = AUDIO_IO_HANDLE_NONE;
        if (mOutput == AUDIO_IO_HANDLE_NONE) {
        if (mOutput == AUDIO_IO_HANDLE_NONE) {
            return output;
            return output;
        }
        }
@@ -688,6 +701,13 @@ audio_io_handle_t Spatializer::detachOutput() {
        output = mOutput;
        output = mOutput;
        mOutput = AUDIO_IO_HANDLE_NONE;
        mOutput = AUDIO_IO_HANDLE_NONE;
        mPoseController.reset();
        mPoseController.reset();

        callback = mSpatializerCallback;
    }

    if (callback != nullptr) {
        callback->onOutputChanged(AUDIO_IO_HANDLE_NONE);
    }
    return output;
    return output;
}
}