hopefully fixe a race condition in sf initialization

if we received a vsync event during SF init, we could crash
as not all objects were ready to go.

Change-Id: Ie11b46e3eb1b37a709dd8757843d444f93dd0189
This commit is contained in:
Mathias Agopian 2012-07-25 21:12:12 -07:00
parent 8630320433
commit 028508cad5
2 changed files with 10 additions and 15 deletions

View File

@ -118,7 +118,7 @@ HWComposer::HWComposer(
property_get("debug.sf.no_hw_vsync", value, "0");
mDebugForceFakeVSync = atoi(value);
bool needVSyncThread = false;
bool needVSyncThread = true;
int err = hw_get_module(HWC_HARDWARE_MODULE_ID, &mModule);
ALOGW_IF(err, "%s module not found", HWC_HARDWARE_MODULE_ID);
if (err == 0) {
@ -136,6 +136,11 @@ HWComposer::HWComposer(
}
if (mHwc) {
if (hwcHasVersion(mHwc, HWC_DEVICE_API_VERSION_0_3)) {
// always turn vsync off when we start
mHwc->methods->eventControl(mHwc, HWC_EVENT_VSYNC, 0);
needVSyncThread = false;
}
if (mHwc->registerProcs) {
mCBContext->hwc = this;
mCBContext->procs.invalidate = &hook_invalidate;
@ -143,17 +148,7 @@ HWComposer::HWComposer(
mHwc->registerProcs(mHwc, &mCBContext->procs);
memset(mCBContext->procs.zero, 0, sizeof(mCBContext->procs.zero));
}
if (hwcHasVersion(mHwc, HWC_DEVICE_API_VERSION_0_3)) {
if (mDebugForceFakeVSync) {
// make sure to turn h/w vsync off in "fake vsync" mode
mHwc->methods->eventControl(mHwc, HWC_EVENT_VSYNC, 0);
}
} else {
needVSyncThread = true;
}
}
} else {
needVSyncThread = true;
}
if (needVSyncThread) {

View File

@ -406,6 +406,10 @@ status_t SurfaceFlinger::readyToRun()
EGLSurface surface = hw->getEGLSurface();
initializeGL(display, surface);
// start the EventThread
mEventThread = new EventThread(this);
mEventQueue.setEventThread(mEventThread);
// initialize the H/W composer
mHwc = new HWComposer(this,
*static_cast<HWComposer::EventHandler *>(this),
@ -414,10 +418,6 @@ status_t SurfaceFlinger::readyToRun()
mHwc->setFrameBuffer(display, surface);
}
// start the EventThread
mEventThread = new EventThread(this);
mEventQueue.setEventThread(mEventThread);
// We're now ready to accept clients...
mReadyToRunBarrier.open();