summaryrefslogtreecommitdiffstats
path: root/include/media/stagefright/foundation/ALooper.h
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2010-06-07 10:18:57 -0700
committerAndreas Huber <andih@google.com>2010-06-07 10:22:07 -0700
commit72961230a5890071bcca436eb5630172ce84ec41 (patch)
treea699be99c292a92bda91f7eca5671a5817488447 /include/media/stagefright/foundation/ALooper.h
parentcbbf27f76b4798cbd91feb70d7555dac0cbf85cb (diff)
downloadframeworks_av-72961230a5890071bcca436eb5630172ce84ec41.zip
frameworks_av-72961230a5890071bcca436eb5630172ce84ec41.tar.gz
frameworks_av-72961230a5890071bcca436eb5630172ce84ec41.tar.bz2
Initial checkin of "foundation" library for future stagefright development.
Change-Id: I11714dcaa647d0437a13e4c5b953b35e712da8f3
Diffstat (limited to 'include/media/stagefright/foundation/ALooper.h')
-rw-r--r--include/media/stagefright/foundation/ALooper.h75
1 files changed, 75 insertions, 0 deletions
diff --git a/include/media/stagefright/foundation/ALooper.h b/include/media/stagefright/foundation/ALooper.h
new file mode 100644
index 0000000..69ad837
--- /dev/null
+++ b/include/media/stagefright/foundation/ALooper.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef A_LOOPER_H_
+
+#define A_LOOPER_H_
+
+#include <media/stagefright/foundation/ABase.h>
+#include <utils/Errors.h>
+#include <utils/KeyedVector.h>
+#include <utils/List.h>
+#include <utils/RefBase.h>
+#include <utils/threads.h>
+
+namespace android {
+
+struct AHandler;
+struct AMessage;
+
+struct ALooper : public RefBase {
+ typedef int32_t event_id;
+ typedef int32_t handler_id;
+
+ ALooper();
+
+ handler_id registerHandler(const sp<AHandler> &handler);
+ void unregisterHandler(handler_id handlerID);
+
+ status_t start(bool runOnCallingThread = false);
+ status_t stop();
+
+ static int64_t GetNowUs();
+
+protected:
+ virtual ~ALooper();
+
+private:
+ friend struct ALooperRoster;
+
+ struct Event {
+ int64_t mWhenUs;
+ sp<AMessage> mMessage;
+ };
+
+ Mutex mLock;
+ Condition mQueueChangedCondition;
+
+ List<Event> mEventQueue;
+
+ struct LooperThread;
+ sp<LooperThread> mThread;
+ bool mRunningLocally;
+
+ void post(const sp<AMessage> &msg, int64_t delayUs);
+ bool loop();
+
+ DISALLOW_EVIL_CONSTRUCTORS(ALooper);
+};
+
+} // namespace android
+
+#endif // A_LOOPER_H_