Loading media/codec2/hal/client/include/codec2/hidl/output.h +1 −0 Original line number Diff line number Diff line Loading @@ -96,6 +96,7 @@ private: uint64_t mBqId; int32_t mMaxDequeueBufferCount; std::shared_ptr<int> mOwner; std::shared_ptr<int> mConsumerAttachCount; // To migrate existing buffers sp<GraphicBuffer> mBuffers[BufferQueueDefs::NUM_BUFFER_SLOTS]; // find a better way std::weak_ptr<_C2BlockPoolData> mPoolDatas[BufferQueueDefs::NUM_BUFFER_SLOTS]; Loading media/codec2/hal/client/output.cpp +33 −3 Original line number Diff line number Diff line Loading @@ -261,6 +261,7 @@ bool OutputBufferQueue::configure(const sp<IGraphicBufferProducer>& igbp, mGeneration = generation; mBqId = bqId; mOwner = std::make_shared<int>(0); mConsumerAttachCount = std::make_shared<int>(0); mMaxDequeueBufferCount = maxDequeueBufferCount; if (igbp == nullptr) { return false; Loading Loading @@ -522,6 +523,7 @@ void OutputBufferQueue::onBufferReleased(uint32_t generation) { std::shared_ptr<C2SurfaceSyncMemory> syncMem; sp<IGraphicBufferProducer> outputIgbp; uint32_t outputGeneration = 0; std::shared_ptr<int> consumerAttachCount; { std::unique_lock<std::mutex> l(mMutex); if (mStopped) { Loading @@ -529,6 +531,7 @@ void OutputBufferQueue::onBufferReleased(uint32_t generation) { } outputIgbp = mIgbp; outputGeneration = mGeneration; consumerAttachCount = mConsumerAttachCount; syncMem = mSyncMem; } Loading @@ -536,15 +539,42 @@ void OutputBufferQueue::onBufferReleased(uint32_t generation) { auto syncVar = syncMem ? syncMem->mem() : nullptr; if (syncVar) { syncVar->lock(); if (consumerAttachCount && *consumerAttachCount > 0) { (*consumerAttachCount)--; } else { syncVar->notifyQueuedLocked(); } syncVar->unlock(); } } } void OutputBufferQueue::onBufferAttached(uint32_t generation) { // TODO (void) generation; std::shared_ptr<C2SurfaceSyncMemory> syncMem; sp<IGraphicBufferProducer> outputIgbp; uint32_t outputGeneration = 0; std::shared_ptr<int> consumerAttachCount; { std::unique_lock<std::mutex> l(mMutex); if (mStopped) { return; } outputIgbp = mIgbp; outputGeneration = mGeneration; consumerAttachCount = mConsumerAttachCount; syncMem = mSyncMem; } if (outputIgbp && generation == outputGeneration) { auto syncVar = syncMem ? syncMem->mem() : nullptr; if (syncVar) { syncVar->lock(); if (consumerAttachCount) { (*consumerAttachCount)++; } syncVar->unlock(); } } } void OutputBufferQueue::pollForRenderedFrames(FrameEventHistoryDelta* delta) { Loading Loading
media/codec2/hal/client/include/codec2/hidl/output.h +1 −0 Original line number Diff line number Diff line Loading @@ -96,6 +96,7 @@ private: uint64_t mBqId; int32_t mMaxDequeueBufferCount; std::shared_ptr<int> mOwner; std::shared_ptr<int> mConsumerAttachCount; // To migrate existing buffers sp<GraphicBuffer> mBuffers[BufferQueueDefs::NUM_BUFFER_SLOTS]; // find a better way std::weak_ptr<_C2BlockPoolData> mPoolDatas[BufferQueueDefs::NUM_BUFFER_SLOTS]; Loading
media/codec2/hal/client/output.cpp +33 −3 Original line number Diff line number Diff line Loading @@ -261,6 +261,7 @@ bool OutputBufferQueue::configure(const sp<IGraphicBufferProducer>& igbp, mGeneration = generation; mBqId = bqId; mOwner = std::make_shared<int>(0); mConsumerAttachCount = std::make_shared<int>(0); mMaxDequeueBufferCount = maxDequeueBufferCount; if (igbp == nullptr) { return false; Loading Loading @@ -522,6 +523,7 @@ void OutputBufferQueue::onBufferReleased(uint32_t generation) { std::shared_ptr<C2SurfaceSyncMemory> syncMem; sp<IGraphicBufferProducer> outputIgbp; uint32_t outputGeneration = 0; std::shared_ptr<int> consumerAttachCount; { std::unique_lock<std::mutex> l(mMutex); if (mStopped) { Loading @@ -529,6 +531,7 @@ void OutputBufferQueue::onBufferReleased(uint32_t generation) { } outputIgbp = mIgbp; outputGeneration = mGeneration; consumerAttachCount = mConsumerAttachCount; syncMem = mSyncMem; } Loading @@ -536,15 +539,42 @@ void OutputBufferQueue::onBufferReleased(uint32_t generation) { auto syncVar = syncMem ? syncMem->mem() : nullptr; if (syncVar) { syncVar->lock(); if (consumerAttachCount && *consumerAttachCount > 0) { (*consumerAttachCount)--; } else { syncVar->notifyQueuedLocked(); } syncVar->unlock(); } } } void OutputBufferQueue::onBufferAttached(uint32_t generation) { // TODO (void) generation; std::shared_ptr<C2SurfaceSyncMemory> syncMem; sp<IGraphicBufferProducer> outputIgbp; uint32_t outputGeneration = 0; std::shared_ptr<int> consumerAttachCount; { std::unique_lock<std::mutex> l(mMutex); if (mStopped) { return; } outputIgbp = mIgbp; outputGeneration = mGeneration; consumerAttachCount = mConsumerAttachCount; syncMem = mSyncMem; } if (outputIgbp && generation == outputGeneration) { auto syncVar = syncMem ? syncMem->mem() : nullptr; if (syncVar) { syncVar->lock(); if (consumerAttachCount) { (*consumerAttachCount)++; } syncVar->unlock(); } } } void OutputBufferQueue::pollForRenderedFrames(FrameEventHistoryDelta* delta) { Loading