diff options
author | Chris Robinson <[email protected]> | 2017-02-05 14:25:17 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2017-02-05 14:25:17 -0800 |
commit | af362c2d05097fce816b5c5d911d6650eb6bef37 (patch) | |
tree | ef1135e0520993248d05c7b0157e8899ac5a3c66 /Alc | |
parent | 428cde5dc26191871111e1edbea85ade952898aa (diff) |
Fix for NULL JNIEnv
Which can happen with native-only apps
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/ALc.c | 6 | ||||
-rw-r--r-- | Alc/backends/opensl.c | 8 |
2 files changed, 9 insertions, 5 deletions
@@ -1179,6 +1179,12 @@ static void CleanupJNIEnv(void* UNUSED(ptr)) void *Android_GetJNIEnv(void) { + if(!gJavaVM) + { + WARN("gJavaVM is NULL!\n"); + return NULL; + } + /* http://developer.android.com/guide/practices/jni.html * * All threads are Linux threads, scheduled by the kernel. They're usually diff --git a/Alc/backends/opensl.c b/Alc/backends/opensl.c index 1e4bcb06..08530d95 100644 --- a/Alc/backends/opensl.c +++ b/Alc/backends/opensl.c @@ -237,13 +237,11 @@ static ALCboolean opensl_reset_playback(ALCdevice *Device) SLInterfaceID id; SLresult result; SLboolean req; + JNIEnv *env; - if((Device->Flags&DEVICE_FREQUENCY_REQUEST)) - sampleRate = Device->Frequency; - else + sampleRate = Device->Frequency; + if(!(Device->Flags&DEVICE_FREQUENCY_REQUEST) && (env=Android_GetJNIEnv()) != NULL) { - JNIEnv *env = Android_GetJNIEnv(); - /* Get necessary stuff for using java.lang.Integer, * android.content.Context, and android.media.AudioManager. */ |