OSDN Git Service

drm_hwcomposer: Do not close duplicate gem handles in nvimporter
authorIsaac Simha <isimha@nvidia.com>
Wed, 14 Oct 2015 18:40:29 +0000 (11:40 -0700)
committerSean Paul <seanpaul@chromium.org>
Thu, 15 Oct 2015 18:35:40 +0000 (14:35 -0400)
When closing gem handles in ReleaseBufferImpl, do not try to close
the same one more than once.

BUG=chrome-os-partner:46443
TEST=Play youtube video, minimize.  Observe no "Failed to close
gem handle" messages in logcat.

Change-Id: I06598f304e3bd167a77f105eb2be86595ada8f4d
Signed-off-by: Isaac Simha <isimha@nvidia.com>
Signed-off-by: Sean Paul <seanpaul@chromium.org>
nvimporter.cpp

index de3ed55..71b3b7f 100644 (file)
@@ -157,10 +157,15 @@ void NvImporter::ReleaseBufferImpl(hwc_drm_bo_t *bo) {
 
     gem_close.handle = bo->gem_handles[i];
     int ret = drmIoctl(drm_->fd(), DRM_IOCTL_GEM_CLOSE, &gem_close);
-    if (ret)
+    if (ret) {
       ALOGE("Failed to close gem handle %d %d", i, ret);
-    else
+    } else {
+      /* Clear any duplicate gem handle as well but don't close again */
+      for(int j = i + 1; j < num_gem_handles; j++)
+        if(bo->gem_handles[j] == bo->gem_handles[i])
+          bo->gem_handles[j] = 0;
       bo->gem_handles[i] = 0;
+    }
   }
 }