summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/TimedEventQueue.cpp
diff options
context:
space:
mode:
authorMarco Nelissen <marcone@google.com>2010-02-19 15:16:57 -0800
committerMarco Nelissen <marcone@google.com>2010-02-19 15:47:51 -0800
commit0df82fcf56668bbde355cac7fb0828368441f6dc (patch)
tree65533d46d362575bc3191332580afdb24e676e49 /media/libstagefright/TimedEventQueue.cpp
parent1f71e77facd0a2b39f4a0be7fa52850533cc121f (diff)
downloadframeworks_av-0df82fcf56668bbde355cac7fb0828368441f6dc.zip
frameworks_av-0df82fcf56668bbde355cac7fb0828368441f6dc.tar.gz
frameworks_av-0df82fcf56668bbde355cac7fb0828368441f6dc.tar.bz2
Make sure that the event callback thread is Java capable in the simulator.
Diffstat (limited to 'media/libstagefright/TimedEventQueue.cpp')
-rw-r--r--media/libstagefright/TimedEventQueue.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/media/libstagefright/TimedEventQueue.cpp b/media/libstagefright/TimedEventQueue.cpp
index d079e70..6307bc5 100644
--- a/media/libstagefright/TimedEventQueue.cpp
+++ b/media/libstagefright/TimedEventQueue.cpp
@@ -28,6 +28,10 @@
#include <media/stagefright/MediaDebug.h>
+#ifdef ANDROID_SIMULATOR
+#include <jni.h>
+#endif
+
namespace android {
TimedEventQueue::TimedEventQueue()
@@ -183,8 +187,26 @@ int64_t TimedEventQueue::getRealTimeUs() {
// static
void *TimedEventQueue::ThreadWrapper(void *me) {
+
+#ifdef ANDROID_SIMULATOR
+ // The simulator runs everything as one process, so any
+ // Binder calls happen on this thread instead of a thread
+ // in another process. We therefore need to make sure that
+ // this thread can do calls into interpreted code.
+ // On the device this is not an issue because the remote
+ // thread will already be set up correctly for this.
+ JavaVM *vm;
+ int numvms;
+ JNI_GetCreatedJavaVMs(&vm, 1, &numvms);
+ JNIEnv *env;
+ vm->AttachCurrentThread(&env, NULL);
+#endif
+
static_cast<TimedEventQueue *>(me)->threadEntry();
+#ifdef ANDROID_SIMULATOR
+ vm->DetachCurrentThread();
+#endif
return NULL;
}