Merge changes from topic "bufferpool2-V2" into main

* changes:
  media.c2 aidl: Use bufferpool2 V2
  media.bufferpool2: support AHardwareBuffer based buffer
This commit is contained in:
Sungtak Lee
2024-01-13 07:23:54 +00:00
committed by Gerrit Code Review
7 changed files with 33 additions and 11 deletions

View File

@@ -26,6 +26,9 @@ aidl_interface {
vendor_available: true, vendor_available: true,
double_loadable: true, double_loadable: true,
srcs: ["android/hardware/media/bufferpool2/*.aidl"], srcs: ["android/hardware/media/bufferpool2/*.aidl"],
headers: [
"HardwareBuffer_aidl",
],
imports: [ imports: [
"android.hardware.common-V2", "android.hardware.common-V2",
"android.hardware.common.fmq-V1", "android.hardware.common.fmq-V1",
@@ -44,10 +47,13 @@ aidl_interface {
"//apex_available:platform", "//apex_available:platform",
"com.android.media.swcodec", "com.android.media.swcodec",
], ],
additional_shared_libraries: [
"libnativewindow",
],
min_sdk_version: "29", min_sdk_version: "29",
}, },
rust: { rust: {
enabled: true, enabled: false,
}, },
}, },
versions_with_info: [ versions_with_info: [
@@ -59,6 +65,6 @@ aidl_interface {
], ],
}, },
], ],
frozen: true, frozen: false,
} }

View File

@@ -35,5 +35,6 @@ package android.hardware.media.bufferpool2;
@VintfStability @VintfStability
parcelable Buffer { parcelable Buffer {
int id; int id;
android.hardware.common.NativeHandle buffer; @nullable android.hardware.common.NativeHandle buffer;
@nullable android.hardware.HardwareBuffer hwbBuffer;
} }

View File

@@ -17,6 +17,7 @@
package android.hardware.media.bufferpool2; package android.hardware.media.bufferpool2;
import android.hardware.common.NativeHandle; import android.hardware.common.NativeHandle;
import android.hardware.HardwareBuffer;
/** /**
* Generic buffer for fast recycling for media/stagefright. * Generic buffer for fast recycling for media/stagefright.
@@ -26,10 +27,14 @@ import android.hardware.common.NativeHandle;
* by a buffer pool, and are recycled to the buffer pool when they are * by a buffer pool, and are recycled to the buffer pool when they are
* no longer referenced by the clients. * no longer referenced by the clients.
* *
* Initially all buffers in media HAL should be NativeHandle(actually native_handle_t).
* HardwareBuffer(actually AHardwareBuffer) for GraphicBuffer is added from V2.
*
* E.g. ion or gralloc buffer * E.g. ion or gralloc buffer
*/ */
@VintfStability @VintfStability
parcelable Buffer { parcelable Buffer {
int id; int id;
NativeHandle buffer; @nullable NativeHandle buffer;
@nullable HardwareBuffer hwbBuffer;
} }

View File

@@ -33,15 +33,16 @@ cc_library {
"libcutils", "libcutils",
"libfmq", "libfmq",
"liblog", "liblog",
"libnativewindow",
"libutils", "libutils",
"android.hardware.media.bufferpool2-V1-ndk", "android.hardware.media.bufferpool2-V2-ndk",
], ],
static_libs: [ static_libs: [
"libaidlcommonsupport", "libaidlcommonsupport",
], ],
export_shared_lib_headers: [ export_shared_lib_headers: [
"libfmq", "libfmq",
"android.hardware.media.bufferpool2-V1-ndk", "android.hardware.media.bufferpool2-V2-ndk",
], ],
double_loadable: true, double_loadable: true,
cflags: [ cflags: [

View File

@@ -757,7 +757,13 @@ BufferPoolStatus BufferPoolClient::Impl::fetchBufferHandle(
return svcSpecific ? svcSpecific : ResultStatus::CRITICAL_ERROR; return svcSpecific ? svcSpecific : ResultStatus::CRITICAL_ERROR;
} }
if (results[0].getTag() == FetchResult::buffer) { if (results[0].getTag() == FetchResult::buffer) {
*handle = ::android::dupFromAidl(results[0].get<FetchResult::buffer>().buffer); if (results[0].get<FetchResult::buffer>().buffer.has_value()) {
*handle = ::android::dupFromAidl(results[0].get<FetchResult::buffer>().buffer.value());
} else {
// TODO: Support HardwareBuffer
ALOGW("handle nullptr");
*handle = nullptr;
}
return ResultStatus::OK; return ResultStatus::OK;
} }
return results[0].get<FetchResult::failure>(); return results[0].get<FetchResult::failure>();

View File

@@ -36,8 +36,9 @@ cc_test {
"libcutils", "libcutils",
"libfmq", "libfmq",
"liblog", "liblog",
"libnativewindow",
"libutils", "libutils",
"android.hardware.media.bufferpool2-V1-ndk", "android.hardware.media.bufferpool2-V2-ndk",
], ],
static_libs: [ static_libs: [
"libaidlcommonsupport", "libaidlcommonsupport",
@@ -59,8 +60,9 @@ cc_test {
"libcutils", "libcutils",
"libfmq", "libfmq",
"liblog", "liblog",
"libnativewindow",
"libutils", "libutils",
"android.hardware.media.bufferpool2-V1-ndk", "android.hardware.media.bufferpool2-V2-ndk",
], ],
static_libs: [ static_libs: [
"libaidlcommonsupport", "libaidlcommonsupport",
@@ -82,8 +84,9 @@ cc_test {
"libcutils", "libcutils",
"libfmq", "libfmq",
"liblog", "liblog",
"libnativewindow",
"libutils", "libutils",
"android.hardware.media.bufferpool2-V1-ndk", "android.hardware.media.bufferpool2-V2-ndk",
], ],
static_libs: [ static_libs: [
"libaidlcommonsupport", "libaidlcommonsupport",

View File

@@ -20,7 +20,7 @@ aidl_interface {
], ],
imports: [ imports: [
"android.hardware.common-V2", "android.hardware.common-V2",
"android.hardware.media.bufferpool2-V1", "android.hardware.media.bufferpool2-V2",
], ],
include_dirs: [ include_dirs: [
"frameworks/native/aidl/gui", "frameworks/native/aidl/gui",