From 898c4c91be8e11b6d5388c623ae80f12ac25fd27 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Tue, 18 May 2010 17:06:55 -0700 Subject: fix the threading issue for setBuffercount() this change introduces R/W locks in the right places. on the server-side, it guarantees that setBufferCount() is synchronized with "retire" and "resize". on the client-side, it guarantees that setBufferCount() is synchronized with "dequeue", "lockbuffer" and "queue" --- libs/surfaceflinger_client/Surface.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'libs/surfaceflinger_client/Surface.cpp') diff --git a/libs/surfaceflinger_client/Surface.cpp b/libs/surfaceflinger_client/Surface.cpp index afbeafb..4d5c0b6 100644 --- a/libs/surfaceflinger_client/Surface.cpp +++ b/libs/surfaceflinger_client/Surface.cpp @@ -678,19 +678,18 @@ int Surface::setBufferCount(int bufferCount) sp s(mSurface); if (s == 0) return NO_INIT; - // FIXME: this needs to be synchronized dequeue/queue + class SetBufferCountIPC : public SharedBufferClient::SetBufferCountCallback { + sp surface; + virtual status_t operator()(int bufferCount) const { + return surface->setBufferCount(bufferCount); + } + public: + SetBufferCountIPC(const sp& surface) : surface(surface) { } + } ipc(s); - status_t err = s->setBufferCount(bufferCount); + status_t err = mSharedBufferClient->setBufferCount(bufferCount, ipc); LOGE_IF(err, "ISurface::setBufferCount(%d) returned %s", bufferCount, strerror(-err)); - if (err == NO_ERROR) { - err = mSharedBufferClient->getStatus(); - LOGE_IF(err, "Surface (identity=%d) state = %d", mIdentity, err); - if (!err) { - // update our local copy of the buffer count - mSharedBufferClient->setBufferCount(bufferCount); - } - } return err; } -- cgit v1.1