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

Commit 1ba31f95 authored by Bo Hu's avatar Bo Hu Committed by Automerger Merge Worker
Browse files

Merge "codecs: enable codec2buffer for 64bit only guest" am: 8f126cb6

Original change: https://android-review.googlesource.com/c/platform/frameworks/av/+/1549099

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Id9a70d5242a0b8bf9441fc6d92dc25b3b653aa02
parents f4e1e3f1 8f126cb6
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