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

Commit 9115668b authored by Sungtak Lee's avatar Sungtak Lee Committed by Automerger Merge Worker
Browse files

Merge changes from topic "reverted-mistakenly-tv" into udc-dev am: 77016c93 am: 902b1496

parents fbcd3b16 902b1496
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -1523,8 +1523,8 @@ c2_status_t Codec2Client::Component::setOutputSurface(
    uint64_t consumerUsage = kDefaultConsumerUsage;
    {
        if (surface) {
            int usage = 0;
            status_t err = surface->query(NATIVE_WINDOW_CONSUMER_USAGE_BITS, &usage);
            uint64_t usage = 0;
            status_t err = surface->getConsumerUsage(&usage);
            if (err != NO_ERROR) {
                ALOGD("setOutputSurface -- failed to get consumer usage bits (%d/%s). ignoring",
                        err, asString(err));
@@ -1537,8 +1537,7 @@ c2_status_t Codec2Client::Component::setOutputSurface(
                // they do not exist inside of C2 scope. Any buffer usage shall be communicated
                // through the sideband channel.

                // do an unsigned conversion as bit-31 may be 1
                consumerUsage = (uint32_t)usage | kDefaultConsumerUsage;
                consumerUsage = usage | kDefaultConsumerUsage;
            }
        }

@@ -1562,6 +1561,8 @@ c2_status_t Codec2Client::Component::setOutputSurface(
                    static_cast<uint64_t>(blockPoolId),
                    bqId == 0 ? nullHgbp : igbp);

    mOutputBufferQueue->expireOldWaiters();

    if (!transStatus.isOk()) {
        LOG(ERROR) << "setOutputSurface -- transaction failed.";
        return C2_TRANSACTION_FAILED;
@@ -1607,6 +1608,7 @@ void Codec2Client::Component::stopUsingOutputSurface(
                       << status << ".";
        }
    }
    mOutputBufferQueue->expireOldWaiters();
}

c2_status_t Codec2Client::Component::connectToInputSurface(
+6 −0
Original line number Diff line number Diff line
@@ -51,6 +51,10 @@ struct OutputBufferQueue {
                   int maxDequeueBufferCount,
                   std::shared_ptr<V1_2::SurfaceSyncObj> *syncObj);

    // If there are waiters to allocate from the old surface, wake up and expire
    // them.
    void expireOldWaiters();

    // Stop using the current output surface. Pending buffer opeations will not
    // perform anymore.
    void stop();
@@ -90,6 +94,8 @@ private:
    std::weak_ptr<_C2BlockPoolData> mPoolDatas[BufferQueueDefs::NUM_BUFFER_SLOTS];
    std::shared_ptr<C2SurfaceSyncMemory> mSyncMem;
    bool mStopped;
    std::mutex mOldMutex;
    std::shared_ptr<C2SurfaceSyncMemory> mOldMem;

    bool registerBuffer(const C2ConstGraphicBlock& block);
};
+17 −1
Original line number Diff line number Diff line
@@ -217,6 +217,7 @@ bool OutputBufferQueue::configure(const sp<IGraphicBufferProducer>& igbp,
    sp<GraphicBuffer> buffers[BufferQueueDefs::NUM_BUFFER_SLOTS];
    std::weak_ptr<_C2BlockPoolData>
            poolDatas[BufferQueueDefs::NUM_BUFFER_SLOTS];
    std::shared_ptr<C2SurfaceSyncMemory> oldMem;
    {
        std::scoped_lock<std::mutex> l(mMutex);
        bool stopped = mStopped;
@@ -238,7 +239,7 @@ bool OutputBufferQueue::configure(const sp<IGraphicBufferProducer>& igbp,
            }
            return false;
        }
        std::shared_ptr<C2SurfaceSyncMemory> oldMem = mSyncMem;
        oldMem = mSyncMem;
        C2SyncVariables *oldSync = mSyncMem ? mSyncMem->mem() : nullptr;
        if (oldSync) {
            oldSync->lock();
@@ -314,11 +315,26 @@ bool OutputBufferQueue::configure(const sp<IGraphicBufferProducer>& igbp,
            newSync->unlock();
        }
    }
    {
        std::scoped_lock<std::mutex> l(mOldMutex);
        mOldMem = oldMem;
    }
    ALOGD("remote graphic buffer migration %zu/%zu",
          success, tryNum);
    return true;
}

void OutputBufferQueue::expireOldWaiters() {
    std::scoped_lock<std::mutex> l(mOldMutex);
    if (mOldMem) {
        C2SyncVariables *oldSync = mOldMem->mem();
        if (oldSync) {
            oldSync->notifyAll();
        }
        mOldMem.reset();
    }
}

void OutputBufferQueue::stop() {
    std::scoped_lock<std::mutex> l(mMutex);
    mStopped = true;