summaryrefslogtreecommitdiffstats
path: root/libs/surfaceflinger/BufferAllocator.cpp
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2009-04-15 18:34:24 -0700
committerMathias Agopian <mathias@google.com>2009-04-15 18:34:24 -0700
commita6b40ba521d5c2fc23da74015531bd4ed8657921 (patch)
tree148f806ad3253b6582f9287750535f3b3bfeb26a /libs/surfaceflinger/BufferAllocator.cpp
parent5f105d38e2c0c45d1d997906a2fa220b001a8e75 (diff)
downloadframeworks_base-a6b40ba521d5c2fc23da74015531bd4ed8657921.zip
frameworks_base-a6b40ba521d5c2fc23da74015531bd4ed8657921.tar.gz
frameworks_base-a6b40ba521d5c2fc23da74015531bd4ed8657921.tar.bz2
fix a rookie mistake causing Singleton<> to be a "multiton". Also improve the BufferMapper's debugging, but turn it off.
Squashed commit of the following: commit 04e9cae7f806bd65f2cfe35c011b47a36773bbe5 Author: Mathias Agopian <mathias@google.com> Date: Wed Apr 15 18:30:30 2009 -0700 fix and improve BufferMapper's tracking of mapped buffers. commit 1a8deaed15811092b2349cc3c40cafb5f722046c Author: Mathias Agopian <mathias@google.com> Date: Wed Apr 15 00:52:02 2009 -0700 fix some bugs with the Singleton<> class. untested. commit ed01cc06ad70cf640ce1258f01189cb1a96fd3a8 Author: Mathias Agopian <mathias@google.com> Date: Tue Apr 14 19:29:25 2009 -0700 some work to debug the Singleton<> template.
Diffstat (limited to 'libs/surfaceflinger/BufferAllocator.cpp')
-rw-r--r--libs/surfaceflinger/BufferAllocator.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/libs/surfaceflinger/BufferAllocator.cpp b/libs/surfaceflinger/BufferAllocator.cpp
index 96a2c32..28fe810 100644
--- a/libs/surfaceflinger/BufferAllocator.cpp
+++ b/libs/surfaceflinger/BufferAllocator.cpp
@@ -19,6 +19,8 @@
#include <utils/CallStack.h>
#include <cutils/ashmem.h>
#include <cutils/log.h>
+
+#include <utils/Singleton.h>
#include <utils/String8.h>
#include <ui/BufferMapper.h>
@@ -32,6 +34,9 @@
namespace android {
// ---------------------------------------------------------------------------
+template<class BufferAllocator> Mutex Singleton<BufferAllocator>::sLock;
+template<> BufferAllocator* Singleton<BufferAllocator>::sInstance(0);
+
Mutex BufferAllocator::sLock;
KeyedVector<buffer_handle_t, BufferAllocator::alloc_rec_t> BufferAllocator::sAllocList;
@@ -106,7 +111,14 @@ status_t BufferAllocator::free(buffer_handle_t handle)
#if ANDROID_GRALLOC_DEBUG
void* base = (void*)(handle->data[2]);
+#endif
+
+ status_t err = mAllocDev->free(mAllocDev, handle);
+ LOGW_IF(err, "free(...) failed %d (%s)", err, strerror(-err));
+
+#if ANDROID_GRALLOC_DEBUG
if (base) {
+ LOGD("freeing mapped handle %p from:", handle);
CallStack s;
s.update();
s.dump("");
@@ -114,9 +126,6 @@ status_t BufferAllocator::free(buffer_handle_t handle)
}
#endif
- status_t err = mAllocDev->free(mAllocDev, handle);
- LOGW_IF(err, "free(...) failed %d (%s)", err, strerror(-err));
-
if (err == NO_ERROR) {
Mutex::Autolock _l(sLock);
KeyedVector<buffer_handle_t, alloc_rec_t>& list(sAllocList);
@@ -129,7 +138,7 @@ status_t BufferAllocator::free(buffer_handle_t handle)
status_t BufferAllocator::map(buffer_handle_t handle, void** addr)
{
Mutex::Autolock _l(mLock);
- status_t err = BufferMapper::get().map(handle, addr);
+ status_t err = BufferMapper::get().map(handle, addr, this);
if (err == NO_ERROR) {
Mutex::Autolock _l(sLock);
KeyedVector<buffer_handle_t, alloc_rec_t>& list(sAllocList);
@@ -145,7 +154,7 @@ status_t BufferAllocator::unmap(buffer_handle_t handle)
{
Mutex::Autolock _l(mLock);
gralloc_module_t* mod = (gralloc_module_t*)mAllocDev->common.module;
- status_t err = BufferMapper::get().unmap(handle);
+ status_t err = BufferMapper::get().unmap(handle, this);
if (err == NO_ERROR) {
Mutex::Autolock _l(sLock);
KeyedVector<buffer_handle_t, alloc_rec_t>& list(sAllocList);