Fix for NULL JNIEnv

Which can happen with native-only apps
This commit is contained in:
Chris Robinson
2017-02-05 14:25:17 -08:00
parent 428cde5dc2
commit af362c2d05
2 changed files with 9 additions and 5 deletions
+6
View File
@@ -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
+3 -5
View File
@@ -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.
*/