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

Commit a222c0b2 authored by bohu's avatar bohu Committed by Bo Hu
Browse files

codecs: enable codec2buffer for 64bit only guest

Apparently, codec2buffer works fine with 64bit only
guest, so enable it to unblock further testing
of mediaserver on 64bit only guest.

BUG: 170418402
Test:
lunch sdk_phone64_x86_64
m -j
using camera app to take a video

Change-Id: I41a24f1174531c2fc29ebd8857c04e74aea5af0a
parent a2211587
Loading
Loading
Loading
Loading
+18 −5
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#define LOG_TAG "Codec2Buffer"
#include <utils/Log.h>

#include <android-base/properties.h>
#include <android/hardware/cas/native/1.0/types.h>
#include <android/hardware/drm/1.0/types.h>
#include <hidlmemory/FrameworkUtils.h>
@@ -580,7 +581,23 @@ GraphicMetadataBuffer::GraphicMetadataBuffer(
}

std::shared_ptr<C2Buffer> GraphicMetadataBuffer::asC2Buffer() {
#ifndef __LP64__
#ifdef __LP64__
    static std::once_flag s_checkOnce;
    static bool s_64bitonly {false};
    std::call_once(s_checkOnce, [&](){
        const std::string abi32list =
        ::android::base::GetProperty("ro.product.cpu.abilist32", "");
        if (abi32list.empty()) {
            s_64bitonly = true;
        }
    });

    if (!s_64bitonly) {
        ALOGE("GraphicMetadataBuffer does not work in 32+64 system if compiled as 64-bit object");
        return nullptr;
    }
#endif

    VideoNativeMetadata *meta = (VideoNativeMetadata *)base();
    ANativeWindowBuffer *buffer = (ANativeWindowBuffer *)meta->pBuffer;
    if (buffer == nullptr) {
@@ -613,10 +630,6 @@ std::shared_ptr<C2Buffer> GraphicMetadataBuffer::asC2Buffer() {
    }
    return C2Buffer::CreateGraphicBuffer(
            block->share(C2Rect(buffer->width, buffer->height), C2Fence()));
#else
    ALOGE("GraphicMetadataBuffer does not work on 64-bit arch");
    return nullptr;
#endif
}

// ConstGraphicBlockBuffer