summaryrefslogtreecommitdiff
path: root/firmware/target/hosted/android/pcm-android.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/hosted/android/pcm-android.c')
-rw-r--r--firmware/target/hosted/android/pcm-android.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/firmware/target/hosted/android/pcm-android.c b/firmware/target/hosted/android/pcm-android.c
index 24881bd3df..edb3503262 100644
--- a/firmware/target/hosted/android/pcm-android.c
+++ b/firmware/target/hosted/android/pcm-android.c
@@ -21,10 +21,13 @@
21 21
22#include <jni.h> 22#include <jni.h>
23#include <stdbool.h> 23#include <stdbool.h>
24#define _SYSTEM_WITH_JNI /* for getJavaEnvironment */
24#include <system.h> 25#include <system.h>
25#include "debug.h" 26#include "debug.h"
26#include "pcm.h" 27#include "pcm.h"
27 28
29extern JNIEnv *env_ptr;
30
28/* infos about our pcm chunks */ 31/* infos about our pcm chunks */
29static size_t pcm_data_size; 32static size_t pcm_data_size;
30static char *pcm_data_start; 33static char *pcm_data_start;
@@ -115,17 +118,17 @@ void pcm_play_dma_start(const void *addr, size_t size)
115 118
116void pcm_play_dma_stop(void) 119void pcm_play_dma_stop(void)
117{ 120{
118 JNIEnv *env_ptr = getJavaEnvironment(); 121 /* NOTE: due to how pcm_play_get_more_callback() works, this is
119 122 * possibly called from pcmSamplesToByteArray(), i.e. another thread.
120 (*env_ptr)->CallVoidMethod(env_ptr, 123 * => We need to discover the env_ptr */
121 RockboxPCM_instance, 124 JNIEnv* env = getJavaEnvironment();
122 stop_method); 125 (*env)->CallVoidMethod(env,
126 RockboxPCM_instance,
127 stop_method);
123} 128}
124 129
125void pcm_play_dma_pause(bool pause) 130void pcm_play_dma_pause(bool pause)
126{ 131{
127 JNIEnv *env_ptr = getJavaEnvironment();
128
129 (*env_ptr)->CallVoidMethod(env_ptr, 132 (*env_ptr)->CallVoidMethod(env_ptr,
130 RockboxPCM_instance, 133 RockboxPCM_instance,
131 play_pause_method, 134 play_pause_method,
@@ -154,7 +157,6 @@ void pcm_play_dma_init(void)
154 * Luckily we only reference the PCM object from here, so it's safe (and 157 * Luckily we only reference the PCM object from here, so it's safe (and
155 * clean) to allocate it here 158 * clean) to allocate it here
156 **/ 159 **/
157 JNIEnv *env_ptr = getJavaEnvironment();
158 JNIEnv e = *env_ptr; 160 JNIEnv e = *env_ptr;
159 /* get the class and its constructor */ 161 /* get the class and its constructor */
160 jclass RockboxPCM_class = e->FindClass(env_ptr, "org/rockbox/RockboxPCM"); 162 jclass RockboxPCM_class = e->FindClass(env_ptr, "org/rockbox/RockboxPCM");
@@ -175,8 +177,6 @@ void pcm_postinit(void)
175 177
176void pcm_set_mixer_volume(int volume) 178void pcm_set_mixer_volume(int volume)
177{ 179{
178 JNIEnv *env_ptr = getJavaEnvironment();
179
180 (*env_ptr)->CallVoidMethod(env_ptr, RockboxPCM_instance, set_volume_method, volume); 180 (*env_ptr)->CallVoidMethod(env_ptr, RockboxPCM_instance, set_volume_method, volume);
181} 181}
182 182