diff options
author | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2011-03-11 19:23:00 +0000 |
---|---|---|
committer | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2011-03-11 19:23:00 +0000 |
commit | c2ee32b22aa50101fc092f610927cfbdd9a2d8f1 (patch) | |
tree | 9104a62064dda0643c9604c63dee83a74c489d91 /firmware | |
parent | 66f2a08f8a37933b9eff79ceabdc2cb42706e48c (diff) | |
download | rockbox-c2ee32b22aa50101fc092f610927cfbdd9a2d8f1.tar.gz rockbox-c2ee32b22aa50101fc092f610927cfbdd9a2d8f1.zip |
Partly revert "Android: use NewGlobalRef for references that are used globally"
The added complexity wasn't needed for most subsystems, as main() never returns
so local references can't be freed.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29570 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/target/hosted/android/lcd-android.c | 11 | ||||
-rw-r--r-- | firmware/target/hosted/android/pcm-android.c | 13 | ||||
-rw-r--r-- | firmware/target/hosted/android/system-android.c | 12 |
3 files changed, 8 insertions, 28 deletions
diff --git a/firmware/target/hosted/android/lcd-android.c b/firmware/target/hosted/android/lcd-android.c index 66ddcd5e3e..f9d7917a5e 100644 --- a/firmware/target/hosted/android/lcd-android.c +++ b/firmware/target/hosted/android/lcd-android.c | |||
@@ -46,7 +46,6 @@ static bool display_on; | |||
46 | void connect_with_java(JNIEnv* env, jobject fb_instance) | 46 | void connect_with_java(JNIEnv* env, jobject fb_instance) |
47 | { | 47 | { |
48 | JNIEnv e = *env; | 48 | JNIEnv e = *env; |
49 | |||
50 | /* Update RockboxFramebuffer_instance */ | 49 | /* Update RockboxFramebuffer_instance */ |
51 | if (!e->IsSameObject(env, RockboxFramebuffer_instance, fb_instance)) { | 50 | if (!e->IsSameObject(env, RockboxFramebuffer_instance, fb_instance)) { |
52 | if (RockboxFramebuffer_instance != NULL) | 51 | if (RockboxFramebuffer_instance != NULL) |
@@ -55,7 +54,7 @@ void connect_with_java(JNIEnv* env, jobject fb_instance) | |||
55 | RockboxFramebuffer_instance = e->NewGlobalRef(env, fb_instance); | 54 | RockboxFramebuffer_instance = e->NewGlobalRef(env, fb_instance); |
56 | } | 55 | } |
57 | 56 | ||
58 | static bool have_class = false; | 57 | static bool have_class; |
59 | if (!have_class) | 58 | if (!have_class) |
60 | { | 59 | { |
61 | jclass fb_class = e->GetObjectClass(env, fb_instance); | 60 | jclass fb_class = e->GetObjectClass(env, fb_instance); |
@@ -77,13 +76,10 @@ void connect_with_java(JNIEnv* env, jobject fb_instance) | |||
77 | java_lcd_init = e->GetMethodID(env, fb_class, | 76 | java_lcd_init = e->GetMethodID(env, fb_class, |
78 | "java_lcd_init", | 77 | "java_lcd_init", |
79 | "(IILjava/nio/ByteBuffer;)V"); | 78 | "(IILjava/nio/ByteBuffer;)V"); |
80 | 79 | ||
81 | jobject buffer = e->NewDirectByteBuffer(env, | 80 | native_buffer = e->NewDirectByteBuffer(env, |
82 | lcd_framebuffer, | 81 | lcd_framebuffer, |
83 | (jlong)sizeof(lcd_framebuffer)); | 82 | (jlong)sizeof(lcd_framebuffer)); |
84 | |||
85 | native_buffer = e->NewGlobalRef(env, buffer); | ||
86 | |||
87 | have_class = true; | 83 | have_class = true; |
88 | } | 84 | } |
89 | /* we need to setup parts for the java object every time */ | 85 | /* we need to setup parts for the java object every time */ |
@@ -96,7 +92,6 @@ void lcd_deinit(void) | |||
96 | JNIEnv *env_ptr = getJavaEnvironment(); | 92 | JNIEnv *env_ptr = getJavaEnvironment(); |
97 | 93 | ||
98 | (*env_ptr)->DeleteGlobalRef(env_ptr, RockboxFramebuffer_instance); | 94 | (*env_ptr)->DeleteGlobalRef(env_ptr, RockboxFramebuffer_instance); |
99 | (*env_ptr)->DeleteGlobalRef(env_ptr, native_buffer); | ||
100 | } | 95 | } |
101 | 96 | ||
102 | /* | 97 | /* |
diff --git a/firmware/target/hosted/android/pcm-android.c b/firmware/target/hosted/android/pcm-android.c index 4b6df7f878..0f59f3f2ab 100644 --- a/firmware/target/hosted/android/pcm-android.c +++ b/firmware/target/hosted/android/pcm-android.c | |||
@@ -33,6 +33,7 @@ static char *pcm_data_start; | |||
33 | static jmethodID play_pause_method; | 33 | static jmethodID play_pause_method; |
34 | static jmethodID stop_method; | 34 | static jmethodID stop_method; |
35 | static jmethodID set_volume_method; | 35 | static jmethodID set_volume_method; |
36 | static jclass RockboxPCM_class; | ||
36 | static jobject RockboxPCM_instance; | 37 | static jobject RockboxPCM_instance; |
37 | 38 | ||
38 | 39 | ||
@@ -157,11 +158,10 @@ void pcm_play_dma_init(void) | |||
157 | JNIEnv *env_ptr = getJavaEnvironment(); | 158 | JNIEnv *env_ptr = getJavaEnvironment(); |
158 | JNIEnv e = *env_ptr; | 159 | JNIEnv e = *env_ptr; |
159 | /* get the class and its constructor */ | 160 | /* get the class and its constructor */ |
160 | jclass RockboxPCM_class = e->FindClass(env_ptr, "org/rockbox/RockboxPCM"); | 161 | RockboxPCM_class = e->FindClass(env_ptr, "org/rockbox/RockboxPCM"); |
161 | jmethodID constructor = e->GetMethodID(env_ptr, RockboxPCM_class, "<init>", "()V"); | 162 | jmethodID constructor = e->GetMethodID(env_ptr, RockboxPCM_class, "<init>", "()V"); |
162 | /* instance = new RockboxPCM() */ | 163 | /* instance = new RockboxPCM() */ |
163 | jobject PCM_instance = e->NewObject(env_ptr, RockboxPCM_class, constructor); | 164 | RockboxPCM_instance = e->NewObject(env_ptr, RockboxPCM_class, constructor); |
164 | RockboxPCM_instance = e->NewGlobalRef(env_ptr, PCM_instance); | ||
165 | /* cache needed methods */ | 165 | /* cache needed methods */ |
166 | play_pause_method = e->GetMethodID(env_ptr, RockboxPCM_class, "play_pause", "(Z)V"); | 166 | play_pause_method = e->GetMethodID(env_ptr, RockboxPCM_class, "play_pause", "(Z)V"); |
167 | set_volume_method = e->GetMethodID(env_ptr, RockboxPCM_class, "set_volume", "(I)V"); | 167 | set_volume_method = e->GetMethodID(env_ptr, RockboxPCM_class, "set_volume", "(I)V"); |
@@ -170,13 +170,6 @@ void pcm_play_dma_init(void) | |||
170 | pcm_play_get_more_callback((void*)&pcm_data_start, &pcm_data_size); | 170 | pcm_play_get_more_callback((void*)&pcm_data_start, &pcm_data_size); |
171 | } | 171 | } |
172 | 172 | ||
173 | void pcm_deinit(void) | ||
174 | { | ||
175 | JNIEnv *env_ptr = getJavaEnvironment(); | ||
176 | |||
177 | (*env_ptr)->DeleteGlobalRef(env_ptr, RockboxPCM_instance); | ||
178 | } | ||
179 | |||
180 | void pcm_postinit(void) | 173 | void pcm_postinit(void) |
181 | { | 174 | { |
182 | } | 175 | } |
diff --git a/firmware/target/hosted/android/system-android.c b/firmware/target/hosted/android/system-android.c index f9f0605b49..c499631132 100644 --- a/firmware/target/hosted/android/system-android.c +++ b/firmware/target/hosted/android/system-android.c | |||
@@ -37,19 +37,13 @@ uintptr_t *stackend; | |||
37 | extern int main(void); | 37 | extern int main(void); |
38 | extern void telephony_init_device(void); | 38 | extern void telephony_init_device(void); |
39 | extern void lcd_deinit(void); | 39 | extern void lcd_deinit(void); |
40 | extern void pcm_deinit(void); | ||
41 | 40 | ||
42 | void system_exception_wait(void) { } | 41 | void system_exception_wait(void) { } |
43 | void system_reboot(void) { } | 42 | void system_reboot(void) { } |
44 | 43 | ||
45 | void power_off(void) | 44 | void power_off(void) |
46 | { | 45 | { |
47 | JNIEnv *env_ptr = getJavaEnvironment(); | ||
48 | |||
49 | lcd_deinit(); | 46 | lcd_deinit(); |
50 | pcm_deinit(); | ||
51 | |||
52 | (*env_ptr)->DeleteGlobalRef(env_ptr, RockboxService_class); | ||
53 | } | 47 | } |
54 | 48 | ||
55 | void system_init(void) | 49 | void system_init(void) |
@@ -62,8 +56,6 @@ void system_init(void) | |||
62 | JNIEXPORT void JNICALL | 56 | JNIEXPORT void JNICALL |
63 | Java_org_rockbox_RockboxService_main(JNIEnv *env, jobject this) | 57 | Java_org_rockbox_RockboxService_main(JNIEnv *env, jobject this) |
64 | { | 58 | { |
65 | jclass class = (*env)->GetObjectClass(env, this); | ||
66 | |||
67 | /* hack!!! we can't have a valid stack pointer otherwise. | 59 | /* hack!!! we can't have a valid stack pointer otherwise. |
68 | * but we don't really need it anyway, thread.c only needs it | 60 | * but we don't really need it anyway, thread.c only needs it |
69 | * for overflow detection which doesn't apply for the main thread | 61 | * for overflow detection which doesn't apply for the main thread |
@@ -73,8 +65,8 @@ Java_org_rockbox_RockboxService_main(JNIEnv *env, jobject this) | |||
73 | stackbegin = stackend = (uintptr_t*) &stack; | 65 | stackbegin = stackend = (uintptr_t*) &stack; |
74 | 66 | ||
75 | (*env)->GetJavaVM(env, &vm_ptr); | 67 | (*env)->GetJavaVM(env, &vm_ptr); |
76 | RockboxService_instance = (*env)->NewGlobalRef(env, this); | 68 | RockboxService_instance = this; |
77 | RockboxService_class = (*env)->NewGlobalRef(env, class); | 69 | RockboxService_class = (*env)->GetObjectClass(env, this); |
78 | 70 | ||
79 | main(); | 71 | main(); |
80 | } | 72 | } |