Merge "Better character set encoding detection"
diff --git a/media/libstagefright/TimedEventQueue.cpp b/media/libstagefright/TimedEventQueue.cpp
index da23fea..dedd186 100644
--- a/media/libstagefright/TimedEventQueue.cpp
+++ b/media/libstagefright/TimedEventQueue.cpp
@@ -127,6 +127,7 @@
QueueItem item;
item.event = event;
item.realtime_us = realtime_us;
+ item.has_wakelock = false;
if (it == mQueue.begin()) {
mQueueHeadChangedCondition.signal();
@@ -134,7 +135,7 @@
if (realtime_us > ALooper::GetNowUs() + kWakelockMinDelay) {
acquireWakeLock_l();
- event->setWakeLock();
+ item.has_wakelock = true;
}
mQueue.insert(it, item);
@@ -190,7 +191,7 @@
ALOGV("cancelling event %d", (*it).event->eventID());
(*it).event->setEventID(0);
- if ((*it).event->hasWakeLock()) {
+ if ((*it).has_wakelock) {
releaseWakeLock_l();
}
it = mQueue.erase(it);
@@ -216,6 +217,7 @@
for (;;) {
int64_t now_us = 0;
sp<Event> event;
+ bool wakeLocked = false;
{
Mutex::Autolock autoLock(mLock);
@@ -282,13 +284,14 @@
// removeEventFromQueue_l will return NULL.
// Otherwise, the QueueItem will be removed
// from the queue and the referenced event returned.
- event = removeEventFromQueue_l(eventID);
+ event = removeEventFromQueue_l(eventID, &wakeLocked);
}
if (event != NULL) {
// Fire event with the lock NOT held.
event->fire(this, now_us);
- if (event->hasWakeLock()) {
+ if (wakeLocked) {
+ Mutex::Autolock autoLock(mLock);
releaseWakeLock_l();
}
}
@@ -296,12 +299,13 @@
}
sp<TimedEventQueue::Event> TimedEventQueue::removeEventFromQueue_l(
- event_id id) {
+ event_id id, bool *wakeLocked) {
for (List<QueueItem>::iterator it = mQueue.begin();
it != mQueue.end(); ++it) {
if ((*it).event->eventID() == id) {
sp<Event> event = (*it).event;
event->setEventID(0);
+ *wakeLocked = (*it).has_wakelock;
mQueue.erase(it);
return event;
}
diff --git a/media/libstagefright/include/TimedEventQueue.h b/media/libstagefright/include/TimedEventQueue.h
index 4e8912d..3e84256 100644
--- a/media/libstagefright/include/TimedEventQueue.h
+++ b/media/libstagefright/include/TimedEventQueue.h
@@ -33,7 +33,7 @@
struct Event : public RefBase {
Event()
- : mEventID(0), mHasWakeLock(false) {
+ : mEventID(0) {
}
virtual ~Event() {}
@@ -42,14 +42,6 @@
return mEventID;
}
- void setWakeLock() {
- mHasWakeLock = true;
- }
-
- bool hasWakeLock() {
- return mHasWakeLock;
- }
-
protected:
virtual void fire(TimedEventQueue *queue, int64_t now_us) = 0;
@@ -57,7 +49,6 @@
friend class TimedEventQueue;
event_id mEventID;
- bool mHasWakeLock;
void setEventID(event_id id) {
mEventID = id;
@@ -127,6 +118,7 @@
struct QueueItem {
sp<Event> event;
int64_t realtime_us;
+ bool has_wakelock;
};
struct StopEvent : public TimedEventQueue::Event {
@@ -153,7 +145,7 @@
static void *ThreadWrapper(void *me);
void threadEntry();
- sp<Event> removeEventFromQueue_l(event_id id);
+ sp<Event> removeEventFromQueue_l(event_id id, bool *wakeLocked);
void acquireWakeLock_l();
void releaseWakeLock_l(bool force = false);