Make int32_t conversion explicit
id has type C2Allocator::id_t, a typedef for uint32_t.
Codec2Client::Component::mAidlBase has type std::shared_ptr<AidlBase>,
where AidlBase is a typedef for
::aidl::android::hardware::media::c2::IComponent.
This IComponent is defined in an auto-generated C++ header,
out/soong/.intermediates/hardware/interfaces/media/c2/aidl/android.hardware.media.c2-V1-ndk-source/gen/include/aidl/android/hardware/media/c2/IComponent.h,
which is generated from
hardware/interfaces/media/c2/aidl/android/hardware/media/c2/IComponent.aidl.
createBlockPool is declared in the AIDL as:
BlockPool createBlockPool(in BlockPoolAllocator allocator);
... and in the C++ header, that is:
virtual ::ndk::ScopedAStatus createBlockPool(const ::aidl::android::hardware::media::c2::IComponent::BlockPoolAllocator& in_allocator, ::aidl::android::hardware::media::c2::IComponent::BlockPool* _aidl_return) = 0;
The parameter has a const-reference type, so the BlockPoolAllocator
argument can be constructed using an implicit constructor.
BlockPoolAllocator has an implicit constructor:
template <typename _Tp, typename = std::enable_if_t<_not_self<_Tp>>>
// NOLINTNEXTLINE(google-explicit-constructor)
constexpr BlockPoolAllocator(_Tp&& _arg)
: _value(std::forward<_Tp>(_arg)) {}
The constructor forwards its argument to _value's constructor:
std::variant<int32_t, std::shared_ptr<::aidl::android::hardware::media::c2::IGraphicBufferAllocator>> _value;
After upgrading libc++, std::variant doesn't do the implicit conversion
from uint32_t to int32_t anymore, so the argument must be converted at
the call site.
The int32_t in the std::variant above appears to come from this AIDL
code:
union BlockPoolAllocator {
int allocatorId;
IGraphicBufferAllocator igba;
}
Bug: 175635923
Test: treehugger
Test: m MODULES-IN-frameworks-av-media-codec2-hal-client
Change-Id: I86e13d5f2ccdc15d139ccc9aacf7bc71257f9125
diff --git a/media/codec2/hal/client/client.cpp b/media/codec2/hal/client/client.cpp
index accb9fd..e3f8b1c 100644
--- a/media/codec2/hal/client/client.cpp
+++ b/media/codec2/hal/client/client.cpp
@@ -1953,7 +1953,8 @@
std::shared_ptr<Codec2Client::Configurable>* configurable) {
if (mAidlBase) {
c2_aidl::IComponent::BlockPool aidlBlockPool;
- ::ndk::ScopedAStatus transStatus = mAidlBase->createBlockPool(id, &aidlBlockPool);
+ ::ndk::ScopedAStatus transStatus = mAidlBase->createBlockPool(static_cast<int32_t>(id),
+ &aidlBlockPool);
c2_status_t status = GetC2Status(transStatus, "createBlockPool");
if (status != C2_OK) {
return status;