提交 a1b9cb9c 编写于 作者: B bbcallen

android: ijksdl: set surface to NULL when reset/release

上级 630e2c67
......@@ -51,16 +51,17 @@ IjkMediaPlayer *ijkmp_android_create(int(*msg_loop)(void*))
void ijkmp_android_set_surface_l(JNIEnv *env, IjkMediaPlayer *mp, jobject android_surface)
{
assert(mp);
assert(mp->ffplayer);
assert(mp->ffplayer->vout);
if (!mp || !mp->ffplayer || !mp->ffplayer->vout)
return;
SDL_VoutAndroid_SetAndroidSurface(env, mp->ffplayer->vout, android_surface);
}
void ijkmp_android_set_surface(JNIEnv *env, IjkMediaPlayer *mp, jobject android_surface)
{
assert(mp);
if (!mp)
return;
MPTRACE("ijkmp_set_android_surface(surface=%p)", (void*)android_surface);
pthread_mutex_lock(&mp->mutex);
ijkmp_android_set_surface_l(env, mp, android_surface);
......
......@@ -242,6 +242,7 @@ IjkMediaPlayer_release(JNIEnv *env, jobject thiz)
return;
// explicit shutdown mp, in case it is not the last mp-ref here
ijkmp_android_set_surface(env, mp, NULL);
ijkmp_shutdown(mp);
jni_set_media_player(env, thiz, NULL);
......@@ -255,6 +256,7 @@ IjkMediaPlayer_reset(JNIEnv *env, jobject thiz)
IjkMediaPlayer *mp = jni_get_media_player(env, thiz);
JNI_CHECK_GOTO(mp, env, NULL, "mpjni: reset: null mp", LABEL_RETURN);
ijkmp_android_set_surface(env, mp, NULL);
ijkmp_reset(mp);
LABEL_RETURN:
......
......@@ -35,13 +35,11 @@ SDL_Vout *SDL_VoutAndroid_CreateForAndroidSurface()
void SDL_VoutAndroid_SetAndroidSurface(JNIEnv *env, SDL_Vout *vout, jobject android_surface)
{
if (!android_surface)
return;
ANativeWindow *native_window = ANativeWindow_fromSurface(env, android_surface);
if (!native_window)
return;
ANativeWindow *native_window = NULL;
if (android_surface)
native_window = ANativeWindow_fromSurface(env, android_surface);
SDL_VoutAndroid_SetNativeWindow(vout, native_window);
ANativeWindow_release(native_window);
if (native_window)
ANativeWindow_release(native_window);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册