summaryrefslogtreecommitdiffstats
path: root/libs/ui/SurfaceComposerClient.cpp
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2009-09-23 15:44:05 -0700
committerMathias Agopian <mathias@google.com>2009-09-23 15:49:32 -0700
commitdd3423c6247965bf67ea30c75e484a6f5d72b1a2 (patch)
tree734b1c8ef5eb7f94b6864d1dac57442e80036d4d /libs/ui/SurfaceComposerClient.cpp
parente95f0b38cde0668ec6872602a4f5e837f39089a4 (diff)
downloadframeworks_native-dd3423c6247965bf67ea30c75e484a6f5d72b1a2.zip
frameworks_native-dd3423c6247965bf67ea30c75e484a6f5d72b1a2.tar.gz
frameworks_native-dd3423c6247965bf67ea30c75e484a6f5d72b1a2.tar.bz2
fix [2132563] stuck in boot animation (framebuffer_device_open: Failed to create flip chain)
Diffstat (limited to 'libs/ui/SurfaceComposerClient.cpp')
-rw-r--r--libs/ui/SurfaceComposerClient.cpp65
1 files changed, 41 insertions, 24 deletions
diff --git a/libs/ui/SurfaceComposerClient.cpp b/libs/ui/SurfaceComposerClient.cpp
index 8401cb6..3baa281 100644
--- a/libs/ui/SurfaceComposerClient.cpp
+++ b/libs/ui/SurfaceComposerClient.cpp
@@ -62,34 +62,42 @@ static SortedVector<sp<SurfaceComposerClient> > gOpenTransactions;
static sp<IMemoryHeap> gServerCblkMemory;
static volatile surface_flinger_cblk_t* gServerCblk;
-const sp<ISurfaceComposer>& _get_surface_manager()
+static sp<ISurfaceComposer> getComposerService()
{
+ sp<ISurfaceComposer> sc;
+ Mutex::Autolock _l(gLock);
if (gSurfaceManager != 0) {
- return gSurfaceManager;
- }
+ sc = gSurfaceManager;
+ } else {
+ // release the lock while we're waiting...
+ gLock.unlock();
+
+ sp<IBinder> binder;
+ sp<IServiceManager> sm = defaultServiceManager();
+ do {
+ binder = sm->getService(String16("SurfaceFlinger"));
+ if (binder == 0) {
+ LOGW("SurfaceFlinger not published, waiting...");
+ usleep(500000); // 0.5 s
+ }
+ } while(binder == 0);
- sp<IBinder> binder;
- sp<IServiceManager> sm = defaultServiceManager();
- do {
- binder = sm->getService(String16("SurfaceFlinger"));
- if (binder == 0) {
- LOGW("SurfaceFlinger not published, waiting...");
- usleep(500000); // 0.5 s
+ // grab the lock again for updating gSurfaceManager
+ gLock.lock();
+ if (gSurfaceManager == 0) {
+ sc = interface_cast<ISurfaceComposer>(binder);
+ gSurfaceManager = sc;
+ } else {
+ sc = gSurfaceManager;
}
- } while(binder == 0);
- sp<ISurfaceComposer> sc(interface_cast<ISurfaceComposer>(binder));
-
- Mutex::Autolock _l(gLock);
- if (gSurfaceManager == 0) {
- gSurfaceManager = sc;
}
- return gSurfaceManager;
+ return sc;
}
static volatile surface_flinger_cblk_t const * get_cblk()
{
if (gServerCblk == 0) {
- const sp<ISurfaceComposer>& sm(_get_surface_manager());
+ sp<ISurfaceComposer> sm(getComposerService());
Mutex::Autolock _l(gLock);
if (gServerCblk == 0) {
gServerCblkMemory = sm->getCblk();
@@ -112,7 +120,7 @@ static inline int compare_type( const layer_state_t& lhs,
SurfaceComposerClient::SurfaceComposerClient()
{
- const sp<ISurfaceComposer>& sm(_get_surface_manager());
+ sp<ISurfaceComposer> sm(getComposerService());
if (sm == 0) {
_init(0, 0);
return;
@@ -133,6 +141,15 @@ SurfaceComposerClient::SurfaceComposerClient(
_init(sm, interface_cast<ISurfaceFlingerClient>(conn));
}
+
+status_t SurfaceComposerClient::linkToComposerDeath(
+ const sp<IBinder::DeathRecipient>& recipient,
+ void* cookie, uint32_t flags)
+{
+ sp<ISurfaceComposer> sm(getComposerService());
+ return sm->asBinder()->linkToDeath(recipient, cookie, flags);
+}
+
void SurfaceComposerClient::_init(
const sp<ISurfaceComposer>& sm, const sp<ISurfaceFlingerClient>& conn)
{
@@ -183,7 +200,7 @@ SurfaceComposerClient::clientForConnection(const sp<IBinder>& conn)
if (client == 0) {
// Need to make a new client.
- const sp<ISurfaceComposer>& sm(_get_surface_manager());
+ sp<ISurfaceComposer> sm(getComposerService());
client = new SurfaceComposerClient(sm, conn);
if (client != 0 && client->initCheck() == NO_ERROR) {
Mutex::Autolock _l(gLock);
@@ -377,7 +394,7 @@ void SurfaceComposerClient::closeGlobalTransaction()
const size_t N = clients.size();
VERBOSE("closeGlobalTransaction (%ld clients)", N);
- const sp<ISurfaceComposer>& sm(_get_surface_manager());
+ sp<ISurfaceComposer> sm(getComposerService());
sm->openGlobalTransaction();
for (size_t i=0; i<N; i++) {
clients[i]->closeTransaction();
@@ -389,20 +406,20 @@ void SurfaceComposerClient::closeGlobalTransaction()
status_t SurfaceComposerClient::freezeDisplay(DisplayID dpy, uint32_t flags)
{
- const sp<ISurfaceComposer>& sm(_get_surface_manager());
+ sp<ISurfaceComposer> sm(getComposerService());
return sm->freezeDisplay(dpy, flags);
}
status_t SurfaceComposerClient::unfreezeDisplay(DisplayID dpy, uint32_t flags)
{
- const sp<ISurfaceComposer>& sm(_get_surface_manager());
+ sp<ISurfaceComposer> sm(getComposerService());
return sm->unfreezeDisplay(dpy, flags);
}
int SurfaceComposerClient::setOrientation(DisplayID dpy,
int orientation, uint32_t flags)
{
- const sp<ISurfaceComposer>& sm(_get_surface_manager());
+ sp<ISurfaceComposer> sm(getComposerService());
return sm->setOrientation(dpy, orientation, flags);
}