Commit 97a7b2c8 authored by Simon Morlat's avatar Simon Morlat
Browse files

use NewGlobalRef for LinphoneCall

parent 5633e418
...@@ -276,8 +276,8 @@ public: ...@@ -276,8 +276,8 @@ public:
if (up==NULL){ if (up==NULL){
jobj=env->NewObject(callClass,callCtrId,(jlong)call); jobj=env->NewObject(callClass,callCtrId,(jlong)call);
jobj=env->NewGlobalRef(jobj);
linphone_call_set_user_pointer(call,(void*)jobj); linphone_call_set_user_pointer(call,(void*)jobj);
//env->NewGlobalRef(jobj);
linphone_call_ref(call); linphone_call_ref(call);
}else{ }else{
jobj=(jobject)up; jobj=(jobject)up;
...@@ -289,6 +289,7 @@ public: ...@@ -289,6 +289,7 @@ public:
static void callStateChange(LinphoneCore *lc, LinphoneCall* call,LinphoneCallState state,const char* message) { static void callStateChange(LinphoneCore *lc, LinphoneCall* call,LinphoneCallState state,const char* message) {
JNIEnv *env = 0; JNIEnv *env = 0;
jint result = jvm->AttachCurrentThread(&env,NULL); jint result = jvm->AttachCurrentThread(&env,NULL);
jobject jcall;
if (result != 0) { if (result != 0) {
ms_error("cannot attach VM\n"); ms_error("cannot attach VM\n");
return; return;
...@@ -297,9 +298,13 @@ public: ...@@ -297,9 +298,13 @@ public:
env->CallVoidMethod(lcData->listener env->CallVoidMethod(lcData->listener
,lcData->callStateId ,lcData->callStateId
,lcData->core ,lcData->core
,lcData->getCall(env,call) ,(jcall=lcData->getCall(env,call))
,env->CallStaticObjectMethod(lcData->callStateClass,lcData->callStateFromIntId,(jint)state), ,env->CallStaticObjectMethod(lcData->callStateClass,lcData->callStateFromIntId,(jint)state),
message ? env->NewStringUTF(message) : NULL); message ? env->NewStringUTF(message) : NULL);
if (state==LinphoneCallReleased){
linphone_call_set_user_pointer(call,NULL);
env->DeleteGlobalRef(jcall);
}
} }
static void callEncryptionChange(LinphoneCore *lc, LinphoneCall* call, bool_t encrypted,const char* authentication_token) { static void callEncryptionChange(LinphoneCore *lc, LinphoneCall* call, bool_t encrypted,const char* authentication_token) {
JNIEnv *env = 0; JNIEnv *env = 0;
...@@ -1032,14 +1037,7 @@ extern "C" jint Java_org_linphone_core_PayloadTypeImpl_getRate(JNIEnv* env,jobj ...@@ -1032,14 +1037,7 @@ extern "C" jint Java_org_linphone_core_PayloadTypeImpl_getRate(JNIEnv* env,jobj
extern "C" void Java_org_linphone_core_LinphoneCallImpl_finalize(JNIEnv* env extern "C" void Java_org_linphone_core_LinphoneCallImpl_finalize(JNIEnv* env
,jobject thiz ,jobject thiz
,jlong ptr) { ,jlong ptr) {
LinphoneCall *call=(LinphoneCall*)ptr; LinphoneCall *call=(LinphoneCall*)ptr;
jobject jobj=(jobject)linphone_call_get_user_pointer(call);
if (jobj==thiz){
//env->DeleteGlobalRef(jobj);
}else{
ms_error("Call being destroyed is inconsistent: thiz=%lu, jobj=%lu",(unsigned long)thiz,(unsigned long)jobj);
}
linphone_call_set_user_pointer(call,NULL);
linphone_call_unref(call); linphone_call_unref(call);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment