summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/MediaCodec.cpp
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2012-10-03 10:16:58 -0700
committerAndreas Huber <andih@google.com>2012-10-03 10:16:58 -0700
commit72c6686ad04feb976ea3d2f816c784e485b55506 (patch)
treeafe501842403a5e0a1a0c4a4830a4751d4c8ef19 /media/libstagefright/MediaCodec.cpp
parent4a114f03a79e157cab9396f986ef947df2255f1d (diff)
downloadframeworks_av-72c6686ad04feb976ea3d2f816c784e485b55506.zip
frameworks_av-72c6686ad04feb976ea3d2f816c784e485b55506.tar.gz
frameworks_av-72c6686ad04feb976ea3d2f816c784e485b55506.tar.bz2
Better power savings with wifi display code.
No more polling the encoder for work to do, the encoder instead notifies if there's activity. Change-Id: Ia707211b4f5c5a6e6b70d750233d204a2d6bb778 related-to-bug: 7248248
Diffstat (limited to 'media/libstagefright/MediaCodec.cpp')
-rw-r--r--media/libstagefright/MediaCodec.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp
index 7f97430..56e6df0 100644
--- a/media/libstagefright/MediaCodec.cpp
+++ b/media/libstagefright/MediaCodec.cpp
@@ -333,6 +333,12 @@ status_t MediaCodec::requestIDRFrame() {
return OK;
}
+void MediaCodec::requestActivityNotification(const sp<AMessage> &notify) {
+ sp<AMessage> msg = new AMessage(kWhatRequestActivityNotification, id());
+ msg->setMessage("notify", notify);
+ msg->post();
+}
+
////////////////////////////////////////////////////////////////////////////////
void MediaCodec::cancelPendingDequeueOperations() {
@@ -498,6 +504,7 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
sendErrorReponse = false;
mFlags |= kFlagStickyError;
+ postActivityNotificationIfPossible();
cancelPendingDequeueOperations();
break;
@@ -508,6 +515,7 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
sendErrorReponse = false;
mFlags |= kFlagStickyError;
+ postActivityNotificationIfPossible();
break;
}
}
@@ -600,6 +608,7 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
(new AMessage)->postReply(mReplyID);
} else {
mFlags |= kFlagOutputBuffersChanged;
+ postActivityNotificationIfPossible();
}
}
break;
@@ -638,6 +647,7 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
mOutputFormat = msg;
mFlags |= kFlagOutputFormatChanged;
+ postActivityNotificationIfPossible();
break;
}
@@ -669,6 +679,8 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
err);
mFlags |= kFlagStickyError;
+ postActivityNotificationIfPossible();
+
cancelPendingDequeueOperations();
}
break;
@@ -680,6 +692,8 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
++mDequeueInputTimeoutGeneration;
mFlags &= ~kFlagDequeueInputPending;
mDequeueInputReplyID = 0;
+ } else {
+ postActivityNotificationIfPossible();
}
break;
}
@@ -709,7 +723,10 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
++mDequeueOutputTimeoutGeneration;
mFlags &= ~kFlagDequeueOutputPending;
mDequeueOutputReplyID = 0;
+ } else {
+ postActivityNotificationIfPossible();
}
+
break;
}
@@ -1145,6 +1162,15 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
break;
}
+ case kWhatRequestActivityNotification:
+ {
+ CHECK(mActivityNotify == NULL);
+ CHECK(msg->findMessage("notify", &mActivityNotify));
+
+ postActivityNotificationIfPossible();
+ break;
+ }
+
default:
TRESPASS();
}
@@ -1210,6 +1236,8 @@ void MediaCodec::setState(State newState) {
mFlags &= ~kFlagOutputFormatChanged;
mFlags &= ~kFlagOutputBuffersChanged;
mFlags &= ~kFlagStickyError;
+
+ mActivityNotify.clear();
}
mState = newState;
@@ -1477,4 +1505,19 @@ status_t MediaCodec::setNativeWindow(
return OK;
}
+void MediaCodec::postActivityNotificationIfPossible() {
+ if (mActivityNotify == NULL) {
+ return;
+ }
+
+ if ((mFlags & (kFlagStickyError
+ | kFlagOutputBuffersChanged
+ | kFlagOutputFormatChanged))
+ || !mAvailPortBuffers[kPortIndexInput].empty()
+ || !mAvailPortBuffers[kPortIndexOutput].empty()) {
+ mActivityNotify->post();
+ mActivityNotify.clear();
+ }
+}
+
} // namespace android