Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 8d37bb0c authored by Ryan Prichard's avatar Ryan Prichard
Browse files

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
parent 90940c49
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment