summaryrefslogtreecommitdiffstats
path: root/libs/ui
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2010-01-22 11:47:55 -0800
committerMathias Agopian <mathias@google.com>2010-01-22 11:47:55 -0800
commit9014726d8954a003323d65ba639b2544f8ecea2e (patch)
tree490f2e83220785fb5cfa2d5ee8161d4c43e85cf8 /libs/ui
parentedfd97c0f2e679e86699a0f6c4df65ea21ecff15 (diff)
downloadframeworks_native-9014726d8954a003323d65ba639b2544f8ecea2e.zip
frameworks_native-9014726d8954a003323d65ba639b2544f8ecea2e.tar.gz
frameworks_native-9014726d8954a003323d65ba639b2544f8ecea2e.tar.bz2
return an error when Surface::lock() is called while the surface is already locked.
Diffstat (limited to 'libs/ui')
-rw-r--r--libs/ui/Surface.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/libs/ui/Surface.cpp b/libs/ui/Surface.cpp
index 24ae27f..c7be05b 100644
--- a/libs/ui/Surface.cpp
+++ b/libs/ui/Surface.cpp
@@ -607,13 +607,21 @@ status_t Surface::lock(SurfaceInfo* info, bool blocking) {
status_t Surface::lock(SurfaceInfo* other, Region* dirtyIn, bool blocking)
{
if (mApiLock.tryLock() != NO_ERROR) {
- LOGE("calling Surface::lock() from different threads!");
+ LOGE("calling Surface::lock from different threads!");
CallStack stack;
stack.update();
stack.dump("Surface::lock called from different threads");
return WOULD_BLOCK;
}
+
+ /* Here we're holding mApiLock */
+ if (mLockedBuffer != 0) {
+ LOGE("Surface::lock failed, already locked");
+ mApiLock.unlock();
+ return INVALID_OPERATION;
+ }
+
// we're intending to do software rendering from this point
setUsage(GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN);
@@ -682,8 +690,8 @@ status_t Surface::lock(SurfaceInfo* other, Region* dirtyIn, bool blocking)
status_t Surface::unlockAndPost()
{
if (mLockedBuffer == 0) {
- LOGE("unlockAndPost failed, no locked buffer");
- return BAD_VALUE;
+ LOGE("Surface::unlockAndPost failed, no locked buffer");
+ return INVALID_OPERATION;
}
status_t err = mLockedBuffer->unlock();