Game Development Reference
In-Depth Information
// Create a new char[] used by jni_send_pixels
// Used to prevent JNI ref table overflows
int iSize = strlen(name);
jbyteArray jSound = (*env)-> NewByteArray(env, iSize);
(*env)->SetByteArrayRegion(env, jSound, 0, iSize, (jbyte *) name);
// Call Java method
(*env)->CallStaticVoidMethod(env, jNativesCls
, jStartSoundMethod
, jSound //(*env)->NewStringUTF(env, name)
, (jint) vol);
(*env)->DeleteLocalRef(env,jSound);
}
/**
* Fires when a background song is requested
*/
void jni_start_music (const char * name, int loop)
{
/*
* Attach to the curr thread; otherwise we get JNI WARNING:
* threadid=3 using env from threadid=15 which aborts the VM
*/
JNIEnv *env;
if ( !g_VM) {
return;
}
(*g_VM)->AttachCurrentThread (g_VM, (void **) &env, NULL);
jmethodID mid = (*env)->GetStaticMethodID(env, jNativesCls
, CB_CLASS_SM_CB
, CB_CLASS_SM_SIG);
if (mid) {
(*env)->CallStaticVoidMethod(env, jNativesCls
, mid
, (*env)->NewStringUTF(env, name)
, (jint) loop );
}
}
Search WWH ::




Custom Search