codec2: switch perferred linear allocator type by pool mask
The preferred linear buffer allocator could be switched between Gralloc BLOB
and ION by runtime property "debug.stagefright.c2-poolmask". ION should be
chosen as fallback allocator type if the pool mask property doesn't enable
the bit of Gralloc BLOB.
Bug: 143180475
Test: make libcodec2_vndk
Test: make libsfplugin_ccodec
Change-Id: I56fcca7f03660bca63a4974aa0f78a6d2a40e585
diff --git a/media/codec2/sfplugin/CCodecBufferChannel.cpp b/media/codec2/sfplugin/CCodecBufferChannel.cpp
index 39f3f35..6ba129f 100644
--- a/media/codec2/sfplugin/CCodecBufferChannel.cpp
+++ b/media/codec2/sfplugin/CCodecBufferChannel.cpp
@@ -826,10 +826,8 @@
bool secure = mComponent->getName().find(".secure") != std::string::npos;
std::shared_ptr<C2AllocatorStore> allocatorStore = GetCodec2PlatformAllocatorStore();
- int poolMask = property_get_int32(
- "debug.stagefright.c2-poolmask",
- 1 << C2PlatformAllocatorStore::ION |
- 1 << C2PlatformAllocatorStore::BUFFERQUEUE);
+ int poolMask = GetCodec2PoolMask();
+ C2PlatformAllocatorStore::id_t preferredLinearId = GetPreferredLinearAllocatorId(poolMask);
if (inputFormat != nullptr) {
bool graphic = (iStreamFormat.value == C2BufferData::GRAPHIC);
@@ -839,7 +837,7 @@
// set default allocator ID.
pools->inputAllocatorId = (graphic) ? C2PlatformAllocatorStore::GRALLOC
- : C2PlatformAllocatorStore::ION;
+ : preferredLinearId;
// query C2PortAllocatorsTuning::input from component. If an allocator ID is obtained
// from component, create the input block pool with given ID. Otherwise, use default IDs.
@@ -978,7 +976,7 @@
// set default allocator ID.
pools->outputAllocatorId = (graphic) ? C2PlatformAllocatorStore::GRALLOC
- : C2PlatformAllocatorStore::ION;
+ : preferredLinearId;
// query C2PortAllocatorsTuning::output from component, or use default allocator if
// unsuccessful.