void ijkmp_dec_ref(IjkMediaPlayer *mp) { if (!mp) return; int ref_count = __sync_sub_and_fetch(&mp->ref_count, 1); if (ref_count == 0) { MPTRACE("ijkmp_dec_ref(): ref=0\n"); ijkmp_shutdown(mp); ijkmp_destroy_p(&mp); } }
static void IjkMediaPlayer_release(JNIEnv *env, jobject thiz) { MPTRACE("IjkMediaPlayer_release"); IjkMediaPlayer *mp = jni_get_media_player(env, thiz); if (!mp) 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); ijkmp_dec_ref_p(&mp); }
static void IjkMediaPlayer_release(JNIEnv *env, jobject thiz) { MPTRACE("IjkMediaPlayer_release"); IjkMediaPlayer *mp = jni_get_media_player(env, thiz); if (!mp) return; // explicit shutdown mp, in case it is not the last mp-ref here ijkmp_android_set_surface(env, mp, NULL ); ijkmp_shutdown(mp); //only delete weak_thiz at release jobject weak_thiz = (jobject) ijkmp_set_weak_thiz(mp, NULL ); (*env)->DeleteGlobalRef(env, weak_thiz); jni_set_media_player(env, thiz, NULL ); ijkmp_dec_ref_p(&mp); }