Skip to content

Commit

Permalink
[Android] Fix some names for JNI and add warnings when functions can …
Browse files Browse the repository at this point in the history
…not be registered
  • Loading branch information
RobDangerous committed Nov 11, 2023
1 parent 810a69b commit d93387b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
5 changes: 4 additions & 1 deletion Backends/System/Android/Sources/kinc/backend/system.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,10 @@ void KincAndroidKeyboardInit() {

int methodTableSize = sizeof(methodTable) / sizeof(methodTable[0]);

(*env)->RegisterNatives(env, clazz, methodTable, methodTableSize);
int failure = (*env)->RegisterNatives(env, clazz, methodTable, methodTableSize);
if (failure != 0) {
kinc_log(KINC_LOG_LEVEL_WARNING, "Failed to register KincActivity.nativeKincKeyPress");
}

(*activity->vm)->DetachCurrentThread(activity->vm);
}
Expand Down
11 changes: 7 additions & 4 deletions Backends/System/Android/Sources/kinc/backend/video.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ void kinc_android_video_shutdown(kinc_android_video_t *video) {

#endif

JNIEXPORT void JNICALL Java_tech_kode_kinc_KincMoviePlayer_nativeCreate(JNIEnv *env, jobject jobj, jstring jpath, jobject surface, jint id) {
JNIEXPORT void JNICALL Java_tech_kinc_KincMoviePlayer_nativeCreate(JNIEnv *env, jobject jobj, jstring jpath, jobject surface, jint id) {
#if KORE_ANDROID_API >= 15 && !defined(KORE_VULKAN)
const char *path = (*env)->GetStringUTFChars(env, jpath, NULL);
kinc_android_video_t *av = malloc(sizeof *av);
Expand All @@ -453,11 +453,14 @@ void KoreAndroidVideoInit() {

// String path, Surface surface, int id
JNINativeMethod methodTable[] = {
{"nativeCreate", "(Ljava/lang/String;Landroid/view/Surface;I)V", (void *)Java_tech_kode_kinc_KincMoviePlayer_nativeCreate}};
{"nativeCreate", "(Ljava/lang/String;Landroid/view/Surface;I)V", (void *)Java_tech_kinc_KincMoviePlayer_nativeCreate}};

int methodTableSize = sizeof(methodTable) / sizeof(methodTable[0]);

(*env)->RegisterNatives(env, clazz, methodTable, methodTableSize);
int failure = (*env)->RegisterNatives(env, clazz, methodTable, methodTableSize);
if (failure != 0) {
kinc_log(KINC_LOG_LEVEL_WARNING, "Failed to register KincMoviePlayer.nativeCreate");
}

(*kinc_android_get_activity()->vm)->DetachCurrentThread(kinc_android_get_activity()->vm);
}
Expand All @@ -475,7 +478,7 @@ void kinc_video_init(kinc_video_t *video, const char *filename) {

JNIEnv *env = NULL;
(*kinc_android_get_activity()->vm)->AttachCurrentThread(kinc_android_get_activity()->vm, &env, NULL);
jclass koreMoviePlayerClass = kinc_android_find_class(env, "tech.kinc.KoreMoviePlayer");
jclass koreMoviePlayerClass = kinc_android_find_class(env, "tech.kinc.KincMoviePlayer");
jmethodID constructor = (*env)->GetMethodID(env, koreMoviePlayerClass, "<init>", "(Ljava/lang/String;)V");
jobject object = (*env)->NewObject(env, koreMoviePlayerClass, constructor, (*env)->NewStringUTF(env, filename));

Expand Down

0 comments on commit d93387b

Please sign in to comment.