diff --git a/components/V4L2DecodeInterface.cpp b/components/V4L2DecodeInterface.cpp index a218f133d9474d8ad24124474ac3597ac193546f..e8c7996b4d98c165bbb20439885be505241d74a2 100644 --- a/components/V4L2DecodeInterface.cpp +++ b/components/V4L2DecodeInterface.cpp @@ -331,7 +331,7 @@ V4L2DecodeInterface::V4L2DecodeInterface(const std::string& name, const C2Allocator::id_t outputAllocators[] = {V4L2AllocatorId::V4L2_BUFFERPOOL}; const C2Allocator::id_t surfaceAllocator = - secureMode ? V4L2AllocatorId::SECURE_GRAPHIC : V4L2AllocatorId::V4L2_BUFFERQUEUE; + secureMode ? V4L2AllocatorId::SECURE_GRAPHIC : C2PlatformAllocatorStore::BUFFERQUEUE; const C2BlockPool::local_id_t outputBlockPools[] = {C2BlockPool::BASIC_GRAPHIC}; addParameter( diff --git a/components/VideoFramePool.cpp b/components/VideoFramePool.cpp index c8ea84267c9bd98eb37ca761e29f880ec01d5fb1..97eea134661e73624cbda9a331325c1f21c982ba 100644 --- a/components/VideoFramePool.cpp +++ b/components/VideoFramePool.cpp @@ -17,8 +17,8 @@ #include <log/log.h> #include <v4l2_codec2/common/VideoTypes.h> -#include <v4l2_codec2/plugin_store/C2VdaBqBlockPool.h> #include <v4l2_codec2/plugin_store/C2VdaPooledBlockPool.h> +#include <v4l2_codec2/plugin_store/DmabufHelpers.h> #include <v4l2_codec2/plugin_store/V4L2AllocatorId.h> using android::hardware::graphics::common::V1_0::BufferUsage; @@ -30,11 +30,20 @@ std::optional<uint32_t> VideoFramePool::getBufferIdFromGraphicBlock(C2BlockPool& const C2Block2D& block) { ALOGV("%s() blockPool.getAllocatorId() = %u", __func__, blockPool.getAllocatorId()); - if (blockPool.getAllocatorId() == android::V4L2AllocatorId::V4L2_BUFFERPOOL) { + switch (blockPool.getAllocatorId()) { + case V4L2AllocatorId::SECURE_GRAPHIC: + FALLTHROUGH; + case C2PlatformAllocatorStore::BUFFERQUEUE: { + auto dmabufId = android::getDmabufId(block.handle()->data[0]); + if (!dmabufId) { + return std::nullopt; + } + return dmabufId.value(); + } + case V4L2AllocatorId::V4L2_BUFFERPOOL: + FALLTHROUGH; + case V4L2AllocatorId::SECURE_LINEAR: return C2VdaPooledBlockPool::getBufferIdFromGraphicBlock(block); - } else if (blockPool.getAllocatorId() == C2PlatformAllocatorStore::BUFFERQUEUE) { - C2VdaBqBlockPool* bqPool = static_cast<C2VdaBqBlockPool*>(&blockPool); - return bqPool->getBufferIdFromGraphicBlock(block); } ALOGE("%s(): unknown allocator ID: %u", __func__, blockPool.getAllocatorId()); @@ -50,9 +59,6 @@ c2_status_t VideoFramePool::requestNewBufferSet(C2BlockPool& blockPool, int32_t if (blockPool.getAllocatorId() == android::V4L2AllocatorId::V4L2_BUFFERPOOL) { C2VdaPooledBlockPool* bpPool = static_cast<C2VdaPooledBlockPool*>(&blockPool); return bpPool->requestNewBufferSet(bufferCount); - } else if (blockPool.getAllocatorId() == C2PlatformAllocatorStore::BUFFERQUEUE) { - C2VdaBqBlockPool* bqPool = static_cast<C2VdaBqBlockPool*>(&blockPool); - return bqPool->requestNewBufferSet(bufferCount, size.width, size.height, format, usage); } ALOGE("%s(): unknown allocator ID: %u", __func__, blockPool.getAllocatorId()); @@ -61,12 +67,6 @@ c2_status_t VideoFramePool::requestNewBufferSet(C2BlockPool& blockPool, int32_t // static bool VideoFramePool::setNotifyBlockAvailableCb(C2BlockPool& blockPool, ::base::OnceClosure cb) { - ALOGV("%s() blockPool.getAllocatorId() = %u", __func__, blockPool.getAllocatorId()); - - if (blockPool.getAllocatorId() == C2PlatformAllocatorStore::BUFFERQUEUE) { - C2VdaBqBlockPool* bqPool = static_cast<C2VdaBqBlockPool*>(&blockPool); - return bqPool->setNotifyBlockAvailableCb(std::move(cb)); - } return false; } diff --git a/plugin_store/V4L2PluginStore.cpp b/plugin_store/V4L2PluginStore.cpp index 2d53c5f88e10a28a33315d4ae961329981dfd859..b116759383a952759133e16cbb94785666dfc34f 100644 --- a/plugin_store/V4L2PluginStore.cpp +++ b/plugin_store/V4L2PluginStore.cpp @@ -12,10 +12,10 @@ #include <mutex> #include <C2AllocatorGralloc.h> +#include <C2BqBufferPriv.h> #include <C2BufferPriv.h> #include <log/log.h> -#include <v4l2_codec2/plugin_store/C2VdaBqBlockPool.h> #include <v4l2_codec2/plugin_store/C2VdaPooledBlockPool.h> #include <v4l2_codec2/plugin_store/V4L2AllocatorId.h> #include <v4l2_codec2/plugin_store/VendorAllocatorLoader.h> @@ -70,14 +70,11 @@ C2BlockPool* createBlockPool(C2Allocator::id_t allocatorId, C2BlockPool::local_i case V4L2AllocatorId::V4L2_BUFFERPOOL: return new C2VdaPooledBlockPool(allocator, poolId); - case V4L2AllocatorId::V4L2_BUFFERQUEUE: - return new C2VdaBqBlockPool(allocator, poolId); - case V4L2AllocatorId::SECURE_LINEAR: return new C2PooledBlockPool(allocator, poolId); case V4L2AllocatorId::SECURE_GRAPHIC: - return new C2VdaBqBlockPool(allocator, poolId); + return new C2BufferQueueBlockPool(allocator, poolId); default: ALOGE("%s(): Unknown allocator id=%u", __func__, allocatorId); diff --git a/plugin_store/include/v4l2_codec2/plugin_store/V4L2AllocatorId.h b/plugin_store/include/v4l2_codec2/plugin_store/V4L2AllocatorId.h index 0808963b21dfdf388d03ed588e6a946da1b1220e..45a470c16d3010781950a7748fe99bc8fc04a05d 100644 --- a/plugin_store/include/v4l2_codec2/plugin_store/V4L2AllocatorId.h +++ b/plugin_store/include/v4l2_codec2/plugin_store/V4L2AllocatorId.h @@ -12,8 +12,7 @@ namespace V4L2AllocatorId { // The allocator ids used for V4L2DecodeComponent. enum : C2AllocatorStore::id_t { - V4L2_BUFFERQUEUE = C2PlatformAllocatorStore::PLATFORM_END, - V4L2_BUFFERPOOL, + V4L2_BUFFERPOOL = C2PlatformAllocatorStore::PLATFORM_END, SECURE_LINEAR, SECURE_GRAPHIC, };