mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
audio: Reuse jmethodID objects
This commit is contained in:
parent
b5a422700a
commit
7e4e762d96
@ -133,21 +133,21 @@ static char* writeToAudioTrack(uintptr_t java_vm, uintptr_t jni_env,
|
|||||||
}
|
}
|
||||||
|
|
||||||
jint result;
|
jint result;
|
||||||
|
static jmethodID write1 = NULL;
|
||||||
|
static jmethodID write2 = NULL;
|
||||||
|
if (!write1) {
|
||||||
|
write1 = (*env)->GetMethodID(env, android_media_AudioTrack, "write", "([BII)I");
|
||||||
|
}
|
||||||
|
if (!write2) {
|
||||||
|
write2 = (*env)->GetMethodID(env, android_media_AudioTrack, "write", "([SII)I");
|
||||||
|
}
|
||||||
switch (bytesPerSample) {
|
switch (bytesPerSample) {
|
||||||
case 1:
|
case 1:
|
||||||
result =
|
result = (*env)->CallIntMethod(env, audioTrack, write1, arrInBytes, 0, length);
|
||||||
(*env)->CallIntMethod(
|
|
||||||
env, audioTrack,
|
|
||||||
(*env)->GetMethodID(env, android_media_AudioTrack, "write", "([BII)I"),
|
|
||||||
arrInBytes, 0, length);
|
|
||||||
(*env)->DeleteLocalRef(env, arrInBytes);
|
(*env)->DeleteLocalRef(env, arrInBytes);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
result =
|
result = (*env)->CallIntMethod(env, audioTrack, write2, arrInShorts, 0, length);
|
||||||
(*env)->CallIntMethod(
|
|
||||||
env, audioTrack,
|
|
||||||
(*env)->GetMethodID(env, android_media_AudioTrack, "write", "([SII)I"),
|
|
||||||
arrInShorts, 0, length);
|
|
||||||
(*env)->DeleteLocalRef(env, arrInShorts);
|
(*env)->DeleteLocalRef(env, arrInShorts);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user