Android: Don't share the JNI environment across threads, but obtain it the

correct way

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29569 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Maurus Cuelenaere 2011-03-11 18:34:35 +00:00
parent 2e5b7aebde
commit 66f2a08f8a
10 changed files with 60 additions and 16 deletions

View file

@ -29,8 +29,8 @@
#include "misc.h"
#include "thread.h"
#include "debug.h"
#include "system.h"
extern JNIEnv *env_ptr;
extern jclass RockboxService_class;
extern jobject RockboxService_instance;
@ -47,6 +47,7 @@ static const struct dim dim = { .width = 200, .height = 200 };
static void track_changed_callback(void *param)
{
struct mp3entry* id3 = (struct mp3entry*)param;
JNIEnv *env_ptr = getJavaEnvironment();
JNIEnv e = *env_ptr;
if (id3)
{
@ -109,6 +110,7 @@ static void track_changed_callback(void *param)
static void track_finished_callback(void *param)
{
(void)param;
JNIEnv *env_ptr = getJavaEnvironment();
JNIEnv e = *env_ptr;
e->CallVoidMethod(env_ptr, NotificationManager_instance,
finishNotification);
@ -122,6 +124,7 @@ static void track_finished_callback(void *param)
void notification_init(void)
{
JNIEnv *env_ptr = getJavaEnvironment();
JNIEnv e = *env_ptr;
jfieldID nNM = e->GetFieldID(env_ptr, RockboxService_class,
"fg_runner", "Lorg/rockbox/Helper/RunForegroundManager;");