summaryrefslogtreecommitdiffstats
path: root/services/surfaceflinger
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2010-12-14 15:51:41 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-12-14 15:51:41 -0800
commitfb88981051118e169d6acfe796f7eab9a827b2e0 (patch)
tree3b2078f019acbd2d2939eea96567f96fd708b16e /services/surfaceflinger
parent5eee3d2b13880c9a486be8fca20128660a19b7f7 (diff)
parentdd17b3eaa99f761e265ff457e335b5a0ff83dafb (diff)
downloadframeworks_native-fb88981051118e169d6acfe796f7eab9a827b2e0.zip
frameworks_native-fb88981051118e169d6acfe796f7eab9a827b2e0.tar.gz
frameworks_native-fb88981051118e169d6acfe796f7eab9a827b2e0.tar.bz2
Merge "fix [3176642] Camera preview turns completely black for multiple toggles between camera and camcorder app"
Diffstat (limited to 'services/surfaceflinger')
-rw-r--r--services/surfaceflinger/Layer.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 80aef5f..2b2f557 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -83,8 +83,28 @@ status_t Layer::setToken(const sp<UserClient>& userClient,
sharedClient, token, mBufferManager.getDefaultBufferCount(),
getIdentity());
- status_t err = mUserClientRef.setToken(userClient, lcblk, token);
+ sp<UserClient> ourClient(mUserClientRef.getClient());
+
+ /*
+ * Here it is guaranteed that userClient != ourClient
+ * (see UserClient::getTokenForSurface()).
+ *
+ * We release the token used by this surface in ourClient below.
+ * This should be safe to do so now, since this layer won't be attached
+ * to this client, it should be okay to reuse that id.
+ *
+ * If this causes problems, an other solution would be to keep a list
+ * of all the {UserClient, token} ever used and release them when the
+ * Layer is destroyed.
+ *
+ */
+
+ if (ourClient != 0) {
+ ourClient->detachLayer(this);
+ }
+
+ status_t err = mUserClientRef.setToken(userClient, lcblk, token);
LOGE_IF(err != NO_ERROR,
"ClientRef::setToken(%p, %p, %u) failed",
userClient.get(), lcblk.get(), token);