Revist C2HandleGralloc::WrapNativeHandle
Do not expose Move semantic of wrapping gralloc handle. And use cloned
handle inside C2HandleGralloc::WrapNativeHandle.
Bug: 123107921
Change-Id: If0335c3788cae2d13da215a998ed266ad3e3704c
diff --git a/media/codec2/sfplugin/C2OMXNode.cpp b/media/codec2/sfplugin/C2OMXNode.cpp
index 9500aed..03d859a 100644
--- a/media/codec2/sfplugin/C2OMXNode.cpp
+++ b/media/codec2/sfplugin/C2OMXNode.cpp
@@ -225,18 +225,14 @@
if (omxBuf.mBufferType == OMXBuffer::kBufferTypeANWBuffer
&& omxBuf.mGraphicBuffer != nullptr) {
std::shared_ptr<C2GraphicAllocation> alloc;
- native_handle_t *clonedHandle = native_handle_clone(omxBuf.mGraphicBuffer->handle);
handle = WrapNativeCodec2GrallocHandle(
- clonedHandle,
+ omxBuf.mGraphicBuffer->handle,
omxBuf.mGraphicBuffer->width,
omxBuf.mGraphicBuffer->height,
omxBuf.mGraphicBuffer->format,
omxBuf.mGraphicBuffer->usage,
omxBuf.mGraphicBuffer->stride);
c2_status_t err = mAllocator->priorGraphicAllocation(handle, &alloc);
- if (clonedHandle) {
- native_handle_delete(clonedHandle);
- }
if (err != OK) {
return UNKNOWN_ERROR;
}
diff --git a/media/codec2/sfplugin/Codec2Buffer.cpp b/media/codec2/sfplugin/Codec2Buffer.cpp
index 1113ae8..597e8f3 100644
--- a/media/codec2/sfplugin/Codec2Buffer.cpp
+++ b/media/codec2/sfplugin/Codec2Buffer.cpp
@@ -578,7 +578,7 @@
ALOGV("VideoNativeMetadata: %dx%d", buffer->width, buffer->height);
C2Handle *handle = WrapNativeCodec2GrallocHandle(
- native_handle_clone(buffer->handle),
+ buffer->handle,
buffer->width,
buffer->height,
buffer->format,