Skip to content
Snippets Groups Projects
Commit 12c3bedc authored by Vova Sharaienko's avatar Vova Sharaienko Committed by Automerger Merge Worker
Browse files

Merge "Use dma-buf inode number as buffer unique id am: 53f82c27" into...

Merge "Use dma-buf inode number as buffer unique id am: 53f82c27" into sc-v2-dev-plus-aosp am: 9cb7cb3f

Original change: https://googleplex-android-review.googlesource.com/c/platform/external/v4l2_codec2/+/16246368

Change-Id: I98652dbfbbd5fc0a32f4f0cd9d9bd65d21eb212f
parents a701b53e 9cb7cb3f
No related branches found
No related tags found
No related merge requests found
...@@ -18,7 +18,6 @@ cc_library_shared { ...@@ -18,7 +18,6 @@ cc_library_shared {
srcs: [ srcs: [
"C2VdaBqBlockPool.cpp", "C2VdaBqBlockPool.cpp",
"C2VdaPooledBlockPool.cpp", "C2VdaPooledBlockPool.cpp",
"DmabufHelpers.cpp",
"H2BGraphicBufferProducer.cpp", "H2BGraphicBufferProducer.cpp",
"V4L2PluginStore.cpp", "V4L2PluginStore.cpp",
"VendorAllocatorLoader.cpp", "VendorAllocatorLoader.cpp",
......
...@@ -9,6 +9,9 @@ ...@@ -9,6 +9,9 @@
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <chrono> #include <chrono>
#include <mutex> #include <mutex>
...@@ -24,7 +27,6 @@ ...@@ -24,7 +27,6 @@
#include <log/log.h> #include <log/log.h>
#include <ui/BufferQueueDefs.h> #include <ui/BufferQueueDefs.h>
#include <v4l2_codec2/plugin_store/DmabufHelpers.h>
#include <v4l2_codec2/plugin_store/H2BGraphicBufferProducer.h> #include <v4l2_codec2/plugin_store/H2BGraphicBufferProducer.h>
#include <v4l2_codec2/plugin_store/V4L2AllocatorId.h> #include <v4l2_codec2/plugin_store/V4L2AllocatorId.h>
...@@ -52,6 +54,20 @@ using ::android::BufferQueueDefs::NUM_BUFFER_SLOTS; ...@@ -52,6 +54,20 @@ using ::android::BufferQueueDefs::NUM_BUFFER_SLOTS;
using ::android::hardware::Return; using ::android::hardware::Return;
using HProducerListener = ::android::hardware::graphics::bufferqueue::V2_0::IProducerListener; using HProducerListener = ::android::hardware::graphics::bufferqueue::V2_0::IProducerListener;
std::optional<unique_id_t> getDmabufId(int dmabufFd) {
struct stat sb {};
if (fstat(dmabufFd, &sb) != 0) {
return std::nullopt;
}
if (sb.st_size == 0) {
ALOGE("Dma-buf size is 0. Please check your kernel is v5.3+");
return std::nullopt;
}
return static_cast<unique_id_t>(sb.st_ino);
}
static c2_status_t asC2Error(status_t err) { static c2_status_t asC2Error(status_t err) {
switch (err) { switch (err) {
case OK: case OK:
......
...@@ -16,6 +16,10 @@ ...@@ -16,6 +16,10 @@
namespace android { namespace android {
// We use the value of dma-buf inode as the unique ID of the graphic buffers.
using unique_id_t = uint32_t;
std::optional<unique_id_t> getDmabufId(int dmabufFd);
/** /**
* The BufferQueue-backed block pool design which supports to request arbitrary count of graphic * The BufferQueue-backed block pool design which supports to request arbitrary count of graphic
* buffers from IGBP, and use this buffer set among codec component and client. * buffers from IGBP, and use this buffer set among codec component and client.
......
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