0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00

hwdec_aimagereader: handle lack of JNI gracefully

Hwdec drivers are always loaded so it's rude to abort.
fixes #13367
This commit is contained in:
sfan5 2024-01-27 22:28:54 +01:00
parent dcf8adf289
commit c6ccabe585

View File

@ -138,6 +138,10 @@ static int init(struct ra_hwdec *hw)
if (!gl_check_extension(exts, "EGL_ANDROID_image_native_buffer"))
return -1;
JNIEnv *env = MP_JNI_GET_ENV(hw);
if (!env)
return -1;
if (!load_lib_functions(p, hw->log))
return -1;
@ -167,8 +171,6 @@ static int init(struct ra_hwdec *hw)
}
assert(window);
JNIEnv *env = MP_JNI_GET_ENV(hw);
assert(env);
jobject surface = p->ANativeWindow_toSurface(env, window);
p->surface = (*env)->NewGlobalRef(env, surface);
(*env)->DeleteLocalRef(env, surface);
@ -192,10 +194,10 @@ static int init(struct ra_hwdec *hw)
static void uninit(struct ra_hwdec *hw)
{
struct priv_owner *p = hw->priv;
JNIEnv *env = MP_JNI_GET_ENV(hw);
assert(env);
if (p->surface) {
JNIEnv *env = MP_JNI_GET_ENV(hw);
assert(env);
(*env)->DeleteGlobalRef(env, p->surface);
p->surface = NULL;
}