summaryrefslogtreecommitdiff
path: root/firmware/target
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target')
-rw-r--r--firmware/target/hosted/android/pcm-android.c12
-rw-r--r--firmware/target/hosted/android/system-android.c26
2 files changed, 32 insertions, 6 deletions
diff --git a/firmware/target/hosted/android/pcm-android.c b/firmware/target/hosted/android/pcm-android.c
index edb3503262..cc8bd9c48a 100644
--- a/firmware/target/hosted/android/pcm-android.c
+++ b/firmware/target/hosted/android/pcm-android.c
@@ -36,6 +36,7 @@ static char *pcm_data_start;
36static jmethodID play_pause_method; 36static jmethodID play_pause_method;
37static jmethodID stop_method; 37static jmethodID stop_method;
38static jmethodID set_volume_method; 38static jmethodID set_volume_method;
39static jclass RockboxPCM_class;
39static jobject RockboxPCM_instance; 40static jobject RockboxPCM_instance;
40 41
41 42
@@ -159,7 +160,7 @@ void pcm_play_dma_init(void)
159 **/ 160 **/
160 JNIEnv e = *env_ptr; 161 JNIEnv e = *env_ptr;
161 /* get the class and its constructor */ 162 /* get the class and its constructor */
162 jclass RockboxPCM_class = e->FindClass(env_ptr, "org/rockbox/RockboxPCM"); 163 RockboxPCM_class = e->FindClass(env_ptr, "org/rockbox/RockboxPCM");
163 jmethodID constructor = e->GetMethodID(env_ptr, RockboxPCM_class, "<init>", "()V"); 164 jmethodID constructor = e->GetMethodID(env_ptr, RockboxPCM_class, "<init>", "()V");
164 /* instance = new RockboxPCM() */ 165 /* instance = new RockboxPCM() */
165 RockboxPCM_instance = e->NewObject(env_ptr, RockboxPCM_class, constructor); 166 RockboxPCM_instance = e->NewObject(env_ptr, RockboxPCM_class, constructor);
@@ -180,6 +181,15 @@ void pcm_set_mixer_volume(int volume)
180 (*env_ptr)->CallVoidMethod(env_ptr, RockboxPCM_instance, set_volume_method, volume); 181 (*env_ptr)->CallVoidMethod(env_ptr, RockboxPCM_instance, set_volume_method, volume);
181} 182}
182 183
184/*
185 * release audio resources */
186void pcm_shutdown(void)
187{
188 JNIEnv e = *env_ptr;
189 jmethodID release = e->GetMethodID(env_ptr, RockboxPCM_class, "release", "()V");
190 e->CallVoidMethod(env_ptr, RockboxPCM_instance, release);
191}
192
183/* Due to limitations of default_event_handler(), parameters gets swallowed when 193/* Due to limitations of default_event_handler(), parameters gets swallowed when
184 * being posted with queue_broadcast(), so workaround this by caching the last 194 * being posted with queue_broadcast(), so workaround this by caching the last
185 * value. 195 * value.
diff --git a/firmware/target/hosted/android/system-android.c b/firmware/target/hosted/android/system-android.c
index 686453cfbb..fba7ff4e2c 100644
--- a/firmware/target/hosted/android/system-android.c
+++ b/firmware/target/hosted/android/system-android.c
@@ -20,6 +20,7 @@
20 ****************************************************************************/ 20 ****************************************************************************/
21 21
22 22
23#include <setjmp.h>
23#include <jni.h> 24#include <jni.h>
24#include "config.h" 25#include "config.h"
25#include "system.h" 26#include "system.h"
@@ -37,10 +38,17 @@ uintptr_t *stackend;
37 38
38extern int main(void); 39extern int main(void);
39extern void telephony_init_device(void); 40extern void telephony_init_device(void);
41extern void pcm_shutdown(void);
40 42
41void system_exception_wait(void) { } 43void system_exception_wait(void) { }
42void system_reboot(void) { } 44void system_reboot(void) { }
43void power_off(void) { } 45
46/* this is used to return from the entry point of the native library. */
47static jmp_buf poweroff_buf;
48void shutdown_hw(void)
49{
50 longjmp(poweroff_buf, 1);
51}
44 52
45void system_init(void) 53void system_init(void)
46{ 54{
@@ -75,10 +83,18 @@ Java_org_rockbox_RockboxService_main(JNIEnv *env, jobject this)
75 83
76 volatile uintptr_t stack = 0; 84 volatile uintptr_t stack = 0;
77 stackbegin = stackend = (uintptr_t*) &stack; 85 stackbegin = stackend = (uintptr_t*) &stack;
78 env_ptr = env; 86 /* setup a jmp_buf to come back later in case of exit */
87 if (setjmp(poweroff_buf) == 0)
88 {
89 env_ptr = env;
90
91 RockboxService_instance = this;
92 RockboxService_class = (*env)->GetObjectClass(env, this);
79 93
80 RockboxService_instance = this; 94 main();
81 RockboxService_class = (*env)->GetObjectClass(env, this); 95 }
82 96
83 main(); 97 pcm_shutdown();
98 /* simply return here. this will allow the VM to clean up objects and do
99 * garbage collection */
84} 100}