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

Commit 8946fa33 authored by Sungtak Lee's avatar Sungtak Lee Committed by android-build-merger
Browse files

Merge "Make BufferQueue based block pool non-blocking" into qt-dev am: d3757001

am: d57f333d

Change-Id: I9f63948cf2120b17cb8520c41d5d70b6cb89617e
parents 0f6d3ddd d57f333d
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -61,6 +61,10 @@ namespace {
constexpr size_t kSmoothnessFactor = 4;
constexpr size_t kRenderingDepth = 3;

// This is for keeping IGBP's buffer dropping logic in legacy mode other
// than making it non-blocking. Do not change this value.
const static size_t kDequeueTimeoutNs = 0;

}  // namespace

CCodecBufferChannel::QueueGuard::QueueGuard(
@@ -1456,6 +1460,7 @@ status_t CCodecBufferChannel::setSurface(const sp<Surface> &newSurface) {
    sp<IGraphicBufferProducer> producer;
    if (newSurface) {
        newSurface->setScalingMode(NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW);
        newSurface->setDequeueTimeout(kDequeueTimeoutNs);
        producer = newSurface->getIGraphicBufferProducer();
        producer->setGenerationNumber(generation);
    } else {
+22 −30
Original line number Diff line number Diff line
@@ -223,7 +223,6 @@ private:
                        }
                    });
            if (!transResult.isOk() || status != android::OK) {
                ALOGD("cannot dequeue buffer %d", status);
                if (transResult.isOk()) {
                    if (status == android::INVALID_OPERATION ||
                        status == android::TIMED_OUT ||
@@ -233,6 +232,7 @@ private:
                        return C2_BLOCKING;
                    }
                }
                ALOGD("cannot dequeue buffer %d", status);
                return C2_BAD_VALUE;
            }
        }
@@ -355,14 +355,9 @@ public:
            return mInit;
        }

        static int kMaxIgbpRetry = 20; // TODO: small number can cause crash in releasing.
        static int kMaxIgbpRetryDelayUs = 10000;

        int curTry = 0;

        while (curTry++ < kMaxIgbpRetry) {
        std::unique_lock<std::mutex> lock(mMutex);
            // TODO: return C2_NO_INIT
        if (mProducerId == 0) {
            std::shared_ptr<C2GraphicAllocation> alloc;
            c2_status_t err = mAllocator->newGraphicAllocation(
@@ -373,7 +368,6 @@ public:
            std::shared_ptr<C2BufferQueueBlockPoolData> poolData =
                    std::make_shared<C2BufferQueueBlockPoolData>(
                            0, (uint64_t)0, ~0, shared_from_this());
                // TODO: config?
            *block = _C2BlockFactory::CreateGraphicBlock(alloc, poolData);
            ALOGV("allocated a buffer successfully");

@@ -382,13 +376,11 @@ public:
        c2_status_t status = fetchFromIgbp_l(width, height, format, usage, block);
        if (status == C2_BLOCKING) {
            lock.unlock();
            // in order not to drain cpu from component's spinning
            ::usleep(kMaxIgbpRetryDelayUs);
                continue;
        }
        return status;
    }
        return C2_BLOCKING;
    }

    void setRenderCallback(const OnRenderCallback &renderCallback) {
        std::lock_guard<std::mutex> lock(mMutex);
+3 −0
Original line number Diff line number Diff line
@@ -780,6 +780,9 @@ status_t ACodec::handleSetSurface(const sp<Surface> &surface) {
    // need to enable allocation when attaching
    surface->getIGraphicBufferProducer()->allowAllocation(true);

    // dequeueBuffer cannot time out
    surface->setDequeueTimeout(-1);

    // for meta data mode, we move dequeud buffers to the new surface.
    // for non-meta mode, we must move all registered buffers
    for (size_t i = 0; i < buffers.size(); ++i) {
+2 −0
Original line number Diff line number Diff line
@@ -2221,6 +2221,7 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
                            }

                            if (mime.startsWithIgnoreCase("video/")) {
                                mSurface->setDequeueTimeout(-1);
                                mSoftRenderer = new SoftwareRenderer(mSurface, mRotationDegrees);
                            }
                        }
@@ -2508,6 +2509,7 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
                                            && (mFlags & kFlagPushBlankBuffersOnShutdown)) {
                                        pushBlankBuffersToNativeWindow(mSurface.get());
                                    }
                                    surface->setDequeueTimeout(-1);
                                    mSoftRenderer = new SoftwareRenderer(surface);
                                    // TODO: check if this was successful
                                } else {