diff options
author | Jimmy Dalqvist <jimmy.dalqvist@sonymobile.com> | 2014-01-14 14:13:52 +0100 |
---|---|---|
committer | Takeshi Aimi <takeshi.aimi@sonymobile.com> | 2014-01-22 15:47:38 +0900 |
commit | 5163c2ef5fe11c9b10d230691ef429035da4c788 (patch) | |
tree | 951999fe49578daaa7386193849b578c3fa6c9ab /media/libstagefright/TimedEventQueue.cpp | |
parent | 96a7b5a9c87ec3f8cadad5bffc06a82f9f4d86d8 (diff) | |
download | frameworks_av-5163c2ef5fe11c9b10d230691ef429035da4c788.zip frameworks_av-5163c2ef5fe11c9b10d230691ef429035da4c788.tar.gz frameworks_av-5163c2ef5fe11c9b10d230691ef429035da4c788.tar.bz2 |
Only increase the counter when we do take a wakelock
We keep track on how many wakelocks we have taken. We always
just take one real wakelock but increase / decrease the
counter every time we try to acquire / release a wakelock.
The counter is always increased even if the power manager is
not ready, leading to an incorrect counter that could cause a
crash when we try to release it.
Make sure we only increase the counter when a wakelock, real
or counted, is taken.
Change-Id: Iad940e052694932f1dad8a1a71fa63601d289d6a
Diffstat (limited to 'media/libstagefright/TimedEventQueue.cpp')
-rw-r--r-- | media/libstagefright/TimedEventQueue.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/media/libstagefright/TimedEventQueue.cpp b/media/libstagefright/TimedEventQueue.cpp index dedd186..0afac69 100644 --- a/media/libstagefright/TimedEventQueue.cpp +++ b/media/libstagefright/TimedEventQueue.cpp @@ -318,7 +318,7 @@ sp<TimedEventQueue::Event> TimedEventQueue::removeEventFromQueue_l( void TimedEventQueue::acquireWakeLock_l() { - if (mWakeLockCount++ == 0) { + if (mWakeLockCount == 0) { CHECK(mWakeLockToken == 0); if (mPowerManager == 0) { // use checkService() to avoid blocking if power service is not up yet @@ -341,21 +341,23 @@ void TimedEventQueue::acquireWakeLock_l() IPCThreadState::self()->restoreCallingIdentity(token); if (status == NO_ERROR) { mWakeLockToken = binder; + mWakeLockCount++; } } + } else { + mWakeLockCount++; } } void TimedEventQueue::releaseWakeLock_l(bool force) { + if (mWakeLockCount == 0) { + return; + } if (force) { - if (mWakeLockCount == 0) { - return; - } // Force wakelock release below by setting reference count to 1. mWakeLockCount = 1; } - CHECK(mWakeLockCount != 0); if (--mWakeLockCount == 0) { CHECK(mWakeLockToken != 0); if (mPowerManager != 0) { |