From 5df775d2f509c76e76a46615fca83dba95299f6e Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Thu, 25 Aug 2011 16:09:06 -0700 Subject: Support for posting messages and synchronously waiting for a response. Change-Id: Id6c7a08c34fd5cb6c4632f78ece9e7898b29e52c --- include/media/stagefright/foundation/ALooperRoster.h | 13 ++++++++++++- include/media/stagefright/foundation/AMessage.h | 11 +++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/media/stagefright/foundation/ALooperRoster.h b/include/media/stagefright/foundation/ALooperRoster.h index c1bd4ed..2e5fd73 100644 --- a/include/media/stagefright/foundation/ALooperRoster.h +++ b/include/media/stagefright/foundation/ALooperRoster.h @@ -31,9 +31,14 @@ struct ALooperRoster { void unregisterHandler(ALooper::handler_id handlerID); - void postMessage(const sp &msg, int64_t delayUs = 0); + status_t postMessage(const sp &msg, int64_t delayUs = 0); void deliverMessage(const sp &msg); + status_t postAndAwaitResponse( + const sp &msg, sp *response); + + void postReply(uint32_t replyID, const sp &reply); + sp findLooper(ALooper::handler_id handlerID); private: @@ -45,6 +50,12 @@ private: Mutex mLock; KeyedVector mHandlers; ALooper::handler_id mNextHandlerID; + uint32_t mNextReplyID; + Condition mRepliesCondition; + + KeyedVector > mReplies; + + status_t postMessage_l(const sp &msg, int64_t delayUs); DISALLOW_EVIL_CONSTRUCTORS(ALooperRoster); }; diff --git a/include/media/stagefright/foundation/AMessage.h b/include/media/stagefright/foundation/AMessage.h index 72dc730..7ec54aa 100644 --- a/include/media/stagefright/foundation/AMessage.h +++ b/include/media/stagefright/foundation/AMessage.h @@ -72,6 +72,17 @@ struct AMessage : public RefBase { void post(int64_t delayUs = 0); + // Posts the message to its target and waits for a response (or error) + // before returning. + status_t postAndAwaitResponse(sp *response); + + // If this returns true, the sender of this message is synchronously + // awaiting a response, the "replyID" can be used to send the response + // via "postReply" below. + bool senderAwaitsResponse(uint32_t *replyID) const; + + void postReply(uint32_t replyID); + // Performs a deep-copy of "this", contained messages are in turn "dup'ed". // Warning: RefBase items, i.e. "objects" are _not_ copied but only have // their refcount incremented. -- cgit v1.1