创建block pool
使用CreateCodec2BlockPool创建codec2的block pool会报错,这段代码在CCodecBufferChannel中可以找到:
std::shared_ptr<C2AllocatorStore> store = GetCodec2PlatformAllocatorStore();
int poolMask = GetCodec2PoolMask();
C2PlatformAllocatorStore::id_t preferredLinearId = GetPreferredLinearAllocatorId(poolMask);
std::shared_ptr<C2BlockPool> pool;
if ((poolMask >> preferredLinearId) & 1) {
err = CreateCodec2BlockPool(preferredLinearId, nullptr, &pool);
} else {
err = C2_NOT_FOUND;
}
报错LOG:
05-16 06:03:01.600 +0000 14826 14826 F DEBUG : backtrace:
05-16 06:03:01.600 +0000 14826 14826 F DEBUG : NOTE: Function names and BuildId information is missing for some frames due
05-16 06:03:01.600 +0000 14826 14826 F DEBUG : NOTE: to unreadable libraries. For unwinds of apps, only shared libraries
05-16 06:03:01.600 +0000 14826 14826 F DEBUG : NOTE: found under the lib/ directory are readable.
05-16 06:03:01.600 +0000 14826 14826 F DEBUG : #00 pc 000000000006d0b8 /system/lib64/libcodec2_vndk.so (android::(anonymous namespace)::_C2BlockPoolCache::_createBlockPool(unsigned int, std::__1::shared_ptr<C2Component const>, unsigned long, std::__1::shared_ptr<C2BlockPool>*)+828) (BuildId: cbfb54bd2fbd0f7588c8bbd79c9a8288)
05-16 06:03:01.600 +0000 14826 14826 F DEBUG : #01 pc 000000000006ed34 /system/lib64/libcodec2_vndk.so (android::CreateCodec2BlockPool(unsigned int, std::__1::shared_ptr<C2Component const>, std::__1::shared_ptr<C2BlockPool>*) (.cfi)+212) (BuildId: cbfb54bd2fbd0f7588c8bbd79c9a8288)
效仿codec2play中的用法也报错:
这段代码在std::make_shared<C2PooledBlockPool>
的时候也是报错,和前面的log是一样的。
std::shared_ptr<C2AllocatorStore> store = GetCodec2PlatformAllocatorStore();
if (!store) {
GST_ERROR("Get codec2 allocator store failed.\n");
}
store->fetchAllocator(C2AllocatorStore::DEFAULT_LINEAR, &allocator);
if (!allocator) {
GST_ERROR("fetch allocator failed.\n");
}
linearPoolId = allocator->getId();
linearPool = std::make_shared<C2PooledBlockPool>(allocator, linearPoolId);
if (!linearPool) {
GST_DEBUG("create linear pool failed.\n");
}
成功的用法:
直接使用GetCodec2BlockPool
获取block pool
,都不用通过AllocatorStore
:
c2_status_t err = C2_NO_INIT;
C2BlockPool::local_id_t inputPoolId = C2BlockPool::BASIC_LINEAR;
err = GetCodec2BlockPool(inputPoolId, nullptr, &linearPool);
未完待续