gralloc1: Add mutexes
Adds mutexes to protect both the buffer list and the descriptor list
from concurrent access
Bug: 29420918
Change-Id: I4d14353ceb167276570c56c9f92d48b28b2d4c53
diff --git a/include/ui/Gralloc1On0Adapter.h b/include/ui/Gralloc1On0Adapter.h
index edcfb65..97c9a89 100644
--- a/include/ui/Gralloc1On0Adapter.h
+++ b/include/ui/Gralloc1On0Adapter.h
@@ -22,6 +22,7 @@
#include <hardware/gralloc1.h>
+#include <mutex>
#include <string>
#include <unordered_map>
#include <vector>
@@ -468,8 +469,10 @@
std::shared_ptr<Buffer> getBuffer(buffer_handle_t bufferHandle);
static std::atomic<gralloc1_buffer_descriptor_t> sNextBufferDescriptorId;
+ std::mutex mDescriptorMutex;
std::unordered_map<gralloc1_buffer_descriptor_t,
std::shared_ptr<Descriptor>> mDescriptors;
+ std::mutex mBufferMutex;
std::unordered_map<buffer_handle_t, std::shared_ptr<Buffer>> mBuffers;
};