Skip to content

Commit

Permalink
Merge "SF could get stuck waiting for vsync when turning the screen o…
Browse files Browse the repository at this point in the history
…ff" into jb-dev
  • Loading branch information
Jeff Brown authored and Android (Google) Code Review committed Jun 15, 2012
2 parents 16272ef + 7d88647 commit 7c24b1d
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions services/surfaceflinger/EventThread.cpp
Expand Up @@ -60,15 +60,15 @@ status_t EventThread::registerDisplayEventConnection(
const sp<EventThread::Connection>& connection) {
Mutex::Autolock _l(mLock);
mDisplayEventConnections.add(connection);
mCondition.signal();
mCondition.broadcast();
return NO_ERROR;
}

status_t EventThread::unregisterDisplayEventConnection(
const wp<EventThread::Connection>& connection) {
Mutex::Autolock _l(mLock);
mDisplayEventConnections.remove(connection);
mCondition.signal();
mCondition.broadcast();
return NO_ERROR;
}

Expand All @@ -85,7 +85,7 @@ void EventThread::setVsyncRate(uint32_t count,
const int32_t new_count = (count == 0) ? -1 : count;
if (connection->count != new_count) {
connection->count = new_count;
mCondition.signal();
mCondition.broadcast();
}
}
}
Expand All @@ -95,32 +95,33 @@ void EventThread::requestNextVsync(
Mutex::Autolock _l(mLock);
if (connection->count < 0) {
connection->count = 0;
mCondition.signal();
mCondition.broadcast();
}
}

void EventThread::onScreenReleased() {
Mutex::Autolock _l(mLock);
// wait for an eventual pending vsync to be serviced
if (!mUseSoftwareVSync) {
while (mVSyncTimestamp) {
mCondition.wait(mLock);
}
// disable reliance on h/w vsync
mUseSoftwareVSync = true;
mCondition.broadcast();
}
// disable reliance on h/w vsync
mUseSoftwareVSync = true;
}

void EventThread::onScreenAcquired() {
Mutex::Autolock _l(mLock);
mUseSoftwareVSync = false;
if (mUseSoftwareVSync) {
// resume use of h/w vsync
mUseSoftwareVSync = false;
mCondition.broadcast();
}
}


void EventThread::onVSyncReceived(int, nsecs_t timestamp) {
Mutex::Autolock _l(mLock);
mVSyncTimestamp = timestamp;
mCondition.signal();
mCondition.broadcast();
}

bool EventThread::threadLoop() {
Expand Down

0 comments on commit 7c24b1d

Please sign in to comment.