gralloc1: Acquire mutex early in release am: 56ec3afb84 am: 37aa42d24b
am: 3dc5241752
Change-Id: If6ce570aef96611e1c820081c3e56e91aab3e159
diff --git a/libs/ui/Gralloc1On0Adapter.cpp b/libs/ui/Gralloc1On0Adapter.cpp
index 111879a..a0bbe63 100644
--- a/libs/ui/Gralloc1On0Adapter.cpp
+++ b/libs/ui/Gralloc1On0Adapter.cpp
@@ -294,6 +294,7 @@
gralloc1_error_t Gralloc1On0Adapter::retain(
const std::shared_ptr<Buffer>& buffer)
{
+ std::lock_guard<std::mutex> lock(mBufferMutex);
buffer->retain();
return GRALLOC1_ERROR_NONE;
}
@@ -301,6 +302,7 @@
gralloc1_error_t Gralloc1On0Adapter::release(
const std::shared_ptr<Buffer>& buffer)
{
+ std::lock_guard<std::mutex> lock(mBufferMutex);
if (!buffer->release()) {
return GRALLOC1_ERROR_NONE;
}
@@ -320,7 +322,6 @@
}
}
- std::lock_guard<std::mutex> lock(mBufferMutex);
mBuffers.erase(handle);
return GRALLOC1_ERROR_NONE;
}