audio: Delete local refs explicitly in JNI (#336)

This commit is contained in:
Hajime Hoshi 2017-04-06 02:12:20 +09:00
parent b0454b874e
commit 713a537637

View File

@ -96,6 +96,7 @@ static char* initAudioTrack(uintptr_t java_vm, uintptr_t jni_env,
android_media_AudioTrack_MODE_STREAM); android_media_AudioTrack_MODE_STREAM);
// Note that *audioTrack will never be released. // Note that *audioTrack will never be released.
*audioTrack = (*env)->NewGlobalRef(env, tmpAudioTrack); *audioTrack = (*env)->NewGlobalRef(env, tmpAudioTrack);
(*env)->DeleteLocalRef(env, tmpAudioTrack);
(*env)->CallVoidMethod( (*env)->CallVoidMethod(
env, *audioTrack, env, *audioTrack,
@ -133,6 +134,7 @@ static char* writeToAudioTrack(uintptr_t java_vm, uintptr_t jni_env,
env, audioTrack, env, audioTrack,
(*env)->GetMethodID(env, android_media_AudioTrack, "write", "([BII)I"), (*env)->GetMethodID(env, android_media_AudioTrack, "write", "([BII)I"),
arrInBytes, 0, length); arrInBytes, 0, length);
(*env)->DeleteLocalRef(env, arrInBytes);
break; break;
case 2: case 2:
result = result =
@ -140,6 +142,7 @@ static char* writeToAudioTrack(uintptr_t java_vm, uintptr_t jni_env,
env, audioTrack, env, audioTrack,
(*env)->GetMethodID(env, android_media_AudioTrack, "write", "([SII)I"), (*env)->GetMethodID(env, android_media_AudioTrack, "write", "([SII)I"),
arrInShorts, 0, length); arrInShorts, 0, length);
(*env)->DeleteLocalRef(env, arrInShorts);
break; break;
} }