am bbdad819: am 7c24b1d4: Merge "SF could get stuck waiting for vsync when turning the screen off" into jb-dev

* commit 'bbdad8193ea3a16e9f65f32f4469959577b400e9':
  SF could get stuck waiting for vsync when turning the screen off
This commit is contained in:
Jeff Brown 2012-06-18 10:52:34 -07:00 committed by Android Git Automerger
commit d50fdb0209
1 changed files with 13 additions and 12 deletions

View File

@ -60,7 +60,7 @@ status_t EventThread::registerDisplayEventConnection(
const sp<EventThread::Connection>& connection) { const sp<EventThread::Connection>& connection) {
Mutex::Autolock _l(mLock); Mutex::Autolock _l(mLock);
mDisplayEventConnections.add(connection); mDisplayEventConnections.add(connection);
mCondition.signal(); mCondition.broadcast();
return NO_ERROR; return NO_ERROR;
} }
@ -68,7 +68,7 @@ status_t EventThread::unregisterDisplayEventConnection(
const wp<EventThread::Connection>& connection) { const wp<EventThread::Connection>& connection) {
Mutex::Autolock _l(mLock); Mutex::Autolock _l(mLock);
mDisplayEventConnections.remove(connection); mDisplayEventConnections.remove(connection);
mCondition.signal(); mCondition.broadcast();
return NO_ERROR; return NO_ERROR;
} }
@ -85,7 +85,7 @@ void EventThread::setVsyncRate(uint32_t count,
const int32_t new_count = (count == 0) ? -1 : count; const int32_t new_count = (count == 0) ? -1 : count;
if (connection->count != new_count) { if (connection->count != new_count) {
connection->count = new_count; connection->count = new_count;
mCondition.signal(); mCondition.broadcast();
} }
} }
} }
@ -95,32 +95,33 @@ void EventThread::requestNextVsync(
Mutex::Autolock _l(mLock); Mutex::Autolock _l(mLock);
if (connection->count < 0) { if (connection->count < 0) {
connection->count = 0; connection->count = 0;
mCondition.signal(); mCondition.broadcast();
} }
} }
void EventThread::onScreenReleased() { void EventThread::onScreenReleased() {
Mutex::Autolock _l(mLock); Mutex::Autolock _l(mLock);
// wait for an eventual pending vsync to be serviced
if (!mUseSoftwareVSync) { if (!mUseSoftwareVSync) {
while (mVSyncTimestamp) { // disable reliance on h/w vsync
mCondition.wait(mLock); mUseSoftwareVSync = true;
} mCondition.broadcast();
} }
// disable reliance on h/w vsync
mUseSoftwareVSync = true;
} }
void EventThread::onScreenAcquired() { void EventThread::onScreenAcquired() {
Mutex::Autolock _l(mLock); 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) { void EventThread::onVSyncReceived(int, nsecs_t timestamp) {
Mutex::Autolock _l(mLock); Mutex::Autolock _l(mLock);
mVSyncTimestamp = timestamp; mVSyncTimestamp = timestamp;
mCondition.signal(); mCondition.broadcast();
} }
bool EventThread::threadLoop() { bool EventThread::threadLoop() {