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

Commit 5d25eacc authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "media.c2 aidl: No sync fence return from fetchGraphicBlock" into main...

Merge "media.c2 aidl: No sync fence return from fetchGraphicBlock" into main am: 0bc8c87f am: cf1567b9

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



Change-Id: I914108327f0b370dd3deee79914147b223056413
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 33da706b cf1567b9
Loading
Loading
Loading
Loading
+30 −16
Original line number Original line Diff line number Diff line
@@ -192,28 +192,25 @@ c2_status_t C2IgbaBlockPool::fetchGraphicBlock(
    c2_status_t res = _fetchGraphicBlock(
    c2_status_t res = _fetchGraphicBlock(
            width, height, format, usage, kBlockingFetchTimeoutNs, &origId, block, &fence);
            width, height, format, usage, kBlockingFetchTimeoutNs, &origId, block, &fence);


    if (res == C2_BLOCKING) {
    if (res == C2_TIMED_OUT) {
        // SyncFence waiting timeout.
        // Usually HAL treats C2_TIMED_OUT as an irrecoverable error.
        // We want HAL to re-try.
        return C2_BLOCKING;
        return C2_BLOCKING;
    }
    }
    if (res != C2_OK) {
    return res;
    return res;
}
}
    // TODO: bundle the fence to the block. Are API changes required?
    res = fence.wait(kSyncFenceWaitNs);
    if (res != C2_OK) {
        bool aidlRet = true;
        ::ndk::ScopedAStatus status = mIgba->deallocate(origId, &aidlRet);
        ALOGE("Waiting a sync fence failed %d aidl(%d: %d)",
              res, status.isOk(), aidlRet);
    }
    return C2_OK;
}


c2_status_t C2IgbaBlockPool::fetchGraphicBlock(
c2_status_t C2IgbaBlockPool::fetchGraphicBlock(
        uint32_t width, uint32_t height, uint32_t format, C2MemoryUsage usage,
        uint32_t width, uint32_t height, uint32_t format, C2MemoryUsage usage,
        std::shared_ptr<C2GraphicBlock> *block, C2Fence *fence) {
        std::shared_ptr<C2GraphicBlock> *block, C2Fence *fence) {
    uint64_t origId;
    uint64_t origId;
    return _fetchGraphicBlock(width, height, format, usage, 0LL, &origId, block, fence);
    c2_status_t res = _fetchGraphicBlock(width, height, format, usage, 0LL, &origId, block, fence);
    if (res == C2_TIMED_OUT) {
        *fence = C2Fence();
        return C2_BLOCKING;
    }
    return res;
}
}


c2_status_t C2IgbaBlockPool::_fetchGraphicBlock(
c2_status_t C2IgbaBlockPool::_fetchGraphicBlock(
@@ -263,10 +260,27 @@ c2_status_t C2IgbaBlockPool::_fetchGraphicBlock(
            }
            }
        }
        }


        *fence = _C2FenceFactory::CreateSyncFence(allocation.fence.release());
        C2Fence syncFence  = _C2FenceFactory::CreateSyncFence(allocation.fence.release());
        AHardwareBuffer *ahwb = allocation.buffer.release(); // This is acquired.
        AHardwareBuffer *ahwb = allocation.buffer.release(); // This is acquired.
        CHECK(AHardwareBuffer_getId(ahwb, origId) == ::android::OK);
        CHECK(AHardwareBuffer_getId(ahwb, origId) == ::android::OK);
        c2_status_t res = CreateGraphicBlockFromAhwb(ahwb, mAllocator, mIgba, block);

        // We are waiting for SyncFence here for backward compatibility.
        // H/W based Sync Fence could be returned to improve pipeline latency.
        //
        // TODO: Add a component configuration for returning sync fence
        // from fetchGraphicBlock() as the C2Fence output param(b/322283520).
        // In the case C2_OK along with GraphicBlock must be returned together.
        c2_status_t res = syncFence.wait(kSyncFenceWaitNs);
        if (res != C2_OK) {
            AHardwareBuffer_release(ahwb);
            bool aidlRet = true;
            ::ndk::ScopedAStatus status = mIgba->deallocate(*origId, &aidlRet);
            ALOGE("Waiting a sync fence failed %d aidl(%d: %d)",
                  res, status.isOk(), aidlRet);
            return C2_TIMED_OUT;
        }

        res = CreateGraphicBlockFromAhwb(ahwb, mAllocator, mIgba, block);
        AHardwareBuffer_release(ahwb);
        AHardwareBuffer_release(ahwb);
        if (res != C2_OK) {
        if (res != C2_OK) {
            bool aidlRet = true;
            bool aidlRet = true;