OSDN Git Service

Android: use native_handle_clone to simplify code
authorLin Johnson <johnson.lin@intel.com>
Wed, 28 Mar 2018 03:16:59 +0000 (11:16 +0800)
committerKalyan Kondapally <kalyan.kondapally@intel.com>
Wed, 28 Mar 2018 08:13:39 +0000 (01:13 -0700)
Jira: None
Tests: Build pass on Android
Signed-off-by: Lin Johnson <johnson.lin@intel.com>
os/android/utils_android.h

index 02176be..a77afaa 100644 (file)
@@ -180,20 +180,9 @@ static uint32_t DrmFormatToHALFormat(int format) {
 }
 
 static native_handle_t *dup_buffer_handle(buffer_handle_t handle) {
-  native_handle_t *new_handle =
-      native_handle_create(handle->numFds, handle->numInts);
-  if (new_handle == NULL)
-    return NULL;
-
-  const int *old_data = handle->data;
-  int *new_data = new_handle->data;
-  for (int i = 0; i < handle->numFds; i++) {
-    *new_data = dup(*old_data);
-    old_data++;
-    new_data++;
-  }
-  memcpy(new_data, old_data, sizeof(int) * handle->numInts);
-
+  native_handle_t *new_handle = native_handle_clone(handle);
+  if(new_handle == NULL)
+    ETRACE("failed to duplicate the handle");
   return new_handle;
 }