aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2017-02-05 14:25:17 -0800
committerChris Robinson <[email protected]>2017-02-05 14:25:17 -0800
commitaf362c2d05097fce816b5c5d911d6650eb6bef37 (patch)
treeef1135e0520993248d05c7b0157e8899ac5a3c66
parent428cde5dc26191871111e1edbea85ade952898aa (diff)
Fix for NULL JNIEnv
Which can happen with native-only apps
-rw-r--r--Alc/ALc.c6
-rw-r--r--Alc/backends/opensl.c8
2 files changed, 9 insertions, 5 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 91ff79af..39e29f9f 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -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.
*/