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

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

Merge "codec2: implement waitable fetch on top of normal fetch" into main am: 17623351

parents 943f1139 17623351
Loading
Loading
Loading
Loading
+5 −13
Original line number Diff line number Diff line
@@ -1046,13 +1046,9 @@ public:
     *                      (unexpected)
     */
    virtual c2_status_t fetchLinearBlock(
            uint32_t capacity __unused, C2MemoryUsage usage __unused,
            uint32_t capacity, C2MemoryUsage usage,
            std::shared_ptr<C2LinearBlock> *block /* nonnull */,
            C2Fence *fence /* nonnull */) {
        *block = nullptr;
        (void) fence;
        return C2_OMITTED;
    }
            C2Fence *fence /* nonnull */);

    /**
     * Blocking fetch for 2D graphic block. Obtains a 2D graphic writable block of given |capacity|
@@ -1096,14 +1092,10 @@ public:
     *                      (unexpected)
     */
    virtual c2_status_t fetchGraphicBlock(
            uint32_t width __unused, uint32_t height __unused, uint32_t format __unused,
            C2MemoryUsage usage __unused,
            uint32_t width, uint32_t height, uint32_t format,
            C2MemoryUsage usage,
            std::shared_ptr<C2GraphicBlock> *block /* nonnull */,
            C2Fence *fence /* nonnull */) {
        *block = nullptr;
        (void) fence;
        return C2_OMITTED;
    }
            C2Fence *fence /* nonnull */);
protected:
    C2BlockPool() = default;
};
+27 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
#include <C2AllocatorGralloc.h>
#include <C2AllocatorIon.h>
#include <C2BufferPriv.h>
#include <C2Debug.h>
#include <C2BlockInternal.h>
#include <C2PlatformSupport.h>
#include <bufferpool/ClientManager.h>
@@ -116,6 +117,32 @@ class BufferDataBuddy : public C2BufferData {

}  // namespace

/*
*/

c2_status_t C2BlockPool::fetchLinearBlock(
        uint32_t capacity, C2MemoryUsage usage,
        std::shared_ptr<C2LinearBlock> *block /* nonnull */,
        C2Fence *fence /* nonnull */) {
    // fall back to non-waitable implementation, as long as it does not return C2_BLOCKING
    c2_status_t result = fetchLinearBlock(capacity, usage, block);
    C2_CHECK_NE(result, C2_BLOCKING);
    *fence = C2Fence();
    return result;
}

c2_status_t C2BlockPool::fetchGraphicBlock(
        uint32_t width, uint32_t height, uint32_t format,
        C2MemoryUsage usage,
        std::shared_ptr<C2GraphicBlock> *block /* nonnull */,
        C2Fence *fence /* nonnull */) {
    // fall back to non-waitable implementation, as long as it does not return C2_BLOCKING
    c2_status_t result = fetchGraphicBlock(width, height, format, usage, block);
    C2_CHECK_NE(result, C2_BLOCKING);
    *fence = C2Fence();
    return result;
}

/* ========================================== 1D BLOCK ========================================= */

/**