From e7b469eded20a3b798455414afe8b9a67e334a89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grisez?= Date: Wed, 15 Oct 2014 14:55:36 +0200 Subject: [PATCH] JNI wrapping of linphone_player_destroy() --- coreapi/linphonecore_jni.cc | 20 +++++++++---------- .../org/linphone/core/LinphoneCore.java | 6 ------ .../org/linphone/core/LinphoneCoreImpl.java | 6 ------ .../org/linphone/core/LinphonePlayerImpl.java | 6 ++++++ 4 files changed, 16 insertions(+), 22 deletions(-) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 4a9c7f158..9bd10557a 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -5295,6 +5295,16 @@ extern "C" void Java_org_linphone_core_LinphonePlayerImpl_close(JNIEnv *env, job linphone_player_close(player); } +extern "C" void Java_org_linphone_core_LinphonePlayerImpl_destroy(JNIEnv *env, jobject jobj, jlong playerPtr) { + LinphonePlayer *player = (LinphonePlayer *)playerPtr; + if(player->user_data) { + delete (LinphonePlayerData *)player->user_data; + } + jobject window_id = (jobject)ms_media_player_get_window_id((MSMediaPlayer *)player->impl); + if(window_id) env->DeleteGlobalRef(window_id); + linphone_player_destroy(player); +} + extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createPlayer(JNIEnv *env, jobject jobj, jlong ptr, jobject window) { jobject window_ref = NULL; MSSndCard *snd_card = ms_snd_card_manager_get_default_playback_card(ms_snd_card_manager_get()); @@ -5312,13 +5322,3 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createPlayer(JNIEnv *en return (jlong)player; } } - -extern "C" void Java_org_linphone_core_LinphoneCoreImpl_destroyPlayer(JNIEnv *env, jobject jobj, jlong playerPtr) { - LinphonePlayer *player = (LinphonePlayer *)playerPtr; - if(player->user_data) { - delete (LinphonePlayerData *)player->user_data; - } - jobject window_id = (jobject)ms_media_player_get_window_id((MSMediaPlayer *)player->impl); - if(window_id) env->DeleteGlobalRef(window_id); - linphone_player_destroy(player); -} diff --git a/java/common/org/linphone/core/LinphoneCore.java b/java/common/org/linphone/core/LinphoneCore.java index dfa2f6bca..fced284f8 100644 --- a/java/common/org/linphone/core/LinphoneCore.java +++ b/java/common/org/linphone/core/LinphoneCore.java @@ -1787,10 +1787,4 @@ public interface LinphoneCore { * @return An object that implement LinphonePlayer */ public LinphonePlayer createPlayer(AndroidVideoWindowImpl window); - - /** - * Destroy a player - * @param player Player to destroy - */ - public void destroyPlayer(LinphonePlayer player); } diff --git a/java/impl/org/linphone/core/LinphoneCoreImpl.java b/java/impl/org/linphone/core/LinphoneCoreImpl.java index 750ec1903..8ba90e937 100644 --- a/java/impl/org/linphone/core/LinphoneCoreImpl.java +++ b/java/impl/org/linphone/core/LinphoneCoreImpl.java @@ -1290,10 +1290,4 @@ class LinphoneCoreImpl implements LinphoneCore { return null; } } - - private native void destroyPlayer(long playerPtr); - @Override - public synchronized void destroyPlayer(LinphonePlayer player) { - - } } diff --git a/java/impl/org/linphone/core/LinphonePlayerImpl.java b/java/impl/org/linphone/core/LinphonePlayerImpl.java index 08168e093..fe486321e 100644 --- a/java/impl/org/linphone/core/LinphonePlayerImpl.java +++ b/java/impl/org/linphone/core/LinphonePlayerImpl.java @@ -61,4 +61,10 @@ public class LinphonePlayerImpl implements LinphonePlayer { public synchronized void close() { close(nativePtr); } + + private native void destroy(long nativePtr); + @Override + protected void finalize() { + destroy(nativePtr); + } }