summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/foundation/ALooper.cpp
diff options
context:
space:
mode:
authorLajos Molnar <lajos@google.com>2015-03-05 14:35:41 -0800
committerLajos Molnar <lajos@google.com>2015-03-10 10:36:09 -0700
commit3f27436a9346f043f52265da1e6a74cde2bffd4d (patch)
treea7404d2ba96071bea1f02f93f6782214fc1e4cc1 /media/libstagefright/foundation/ALooper.cpp
parent0655386a0dc15fc31883d2e38917ff0e9db89ae7 (diff)
downloadframeworks_av-3f27436a9346f043f52265da1e6a74cde2bffd4d.zip
frameworks_av-3f27436a9346f043f52265da1e6a74cde2bffd4d.tar.gz
frameworks_av-3f27436a9346f043f52265da1e6a74cde2bffd4d.tar.bz2
stagefright: don't use ALooperRoster mutex for reply handling
Change replyID-s from uint32_t to an object Move reply handling into the loopers (to reuse a common mutex) Bug: 19607784 Change-Id: Iaa035b846c424c5687ed17ce1079b325e86c54be
Diffstat (limited to 'media/libstagefright/foundation/ALooper.cpp')
-rw-r--r--media/libstagefright/foundation/ALooper.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/media/libstagefright/foundation/ALooper.cpp b/media/libstagefright/foundation/ALooper.cpp
index 617d32b..90b5f68 100644
--- a/media/libstagefright/foundation/ALooper.cpp
+++ b/media/libstagefright/foundation/ALooper.cpp
@@ -16,6 +16,9 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "ALooper"
+
+#include <media/stagefright/foundation/ADebug.h>
+
#include <utils/Log.h>
#include <sys/time.h>
@@ -220,4 +223,29 @@ bool ALooper::loop() {
return true;
}
+// to be called by AMessage::postAndAwaitResponse only
+sp<AReplyToken> ALooper::createReplyToken() {
+ return new AReplyToken(this);
+}
+
+// to be called by AMessage::postAndAwaitResponse only
+status_t ALooper::awaitResponse(const sp<AReplyToken> &replyToken, sp<AMessage> *response) {
+ // return status in case we want to handle an interrupted wait
+ Mutex::Autolock autoLock(mRepliesLock);
+ CHECK(replyToken != NULL);
+ while (!replyToken->retrieveReply(response)) {
+ mRepliesCondition.wait(mRepliesLock);
+ }
+ return OK;
+}
+
+status_t ALooper::postReply(const sp<AReplyToken> &replyToken, const sp<AMessage> &reply) {
+ Mutex::Autolock autoLock(mRepliesLock);
+ status_t err = replyToken->setReply(reply);
+ if (err == OK) {
+ mRepliesCondition.broadcast();
+ }
+ return err;
+}
+
} // namespace android