Fix ec calibration crash in Android

This commit is contained in:
Sylvain Berfini 2014-12-11 11:16:15 +01:00
parent 26620d4c0f
commit 95de57a6c6
4 changed files with 40 additions and 29 deletions

View file

@ -763,17 +763,24 @@ public:
ms_error("cannot attach VM");
return;
}
LinphoneCoreVTable *table = linphone_core_get_current_vtable(lc);
LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_v_table_get_user_data(table);
env->CallVoidMethod(lcData->listener
,lcData->ecCalibrationStatusId
,lcData->core
,env->CallStaticObjectMethod(lcData->ecCalibratorStatusClass,lcData->ecCalibratorStatusFromIntId,(jint)status)
,delay_ms
,data ? data : NULL);
if (data != NULL &&status !=LinphoneEcCalibratorInProgress ) {
//final state, releasing global ref
env->DeleteGlobalRef((jobject)data);
LinphoneCoreVTable *table = (LinphoneCoreVTable*) data;
if (table) {
LinphoneCoreData* lcData = (LinphoneCoreData*) linphone_core_v_table_get_user_data(table);
if (lcData->ecCalibrationStatusId) {
jobject ecData = env->NewGlobalRef((jobject) data);
jobject state = env->CallStaticObjectMethod(lcData->ecCalibratorStatusClass, lcData->ecCalibratorStatusFromIntId, (jint)status);
env->CallVoidMethod(lcData->listener
,lcData->ecCalibrationStatusId
,lcData->core
,state
,delay_ms
,ecData);
env->DeleteGlobalRef(ecData);
}
if (status != LinphoneEcCalibratorInProgress) {
linphone_core_v_table_destroy(table);
}
}
}
@ -1727,11 +1734,11 @@ extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_startEchoCalibration(JNI
,jobject thiz
,jlong lc
,jobject data) {
return (jint)linphone_core_start_echo_calibration((LinphoneCore*)lc
, LinphoneCoreData::ecCalibrationStatus
, NULL
, NULL
, data?env->NewGlobalRef(data):NULL);
LinphoneCoreVTable *vTable = linphone_core_v_table_new();
LinphoneCoreData* ldata = new LinphoneCoreData(env, thiz, vTable, data);
linphone_core_v_table_set_user_data(vTable, ldata);
return (jint)linphone_core_start_echo_calibration((LinphoneCore*)lc, ldata->ecCalibrationStatus, NULL, NULL, vTable);
}

View file

@ -20,6 +20,7 @@ package org.linphone.core;
import java.util.Vector;
import org.linphone.core.LinphoneCoreListener.LinphoneEchoCalibrationListener;
import org.linphone.mediastream.video.AndroidVideoWindowImpl;
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
@ -1057,10 +1058,10 @@ public interface LinphoneCore {
/**
* Start an echo calibration of the sound devices, in order to find adequate settings for the echo canceler automatically.
* status is notified to {@link LinphoneCoreListener#ecCalibrationStatus(EcCalibratorStatus, int, Object)}
* @param User object
* @param listener the LinphoneEchoCalibrationListener to call when the calibration is done
* @throws LinphoneCoreException if operation is still in progress;
**/
void startEchoCalibration(Object data) throws LinphoneCoreException;
void startEchoCalibration(LinphoneEchoCalibrationListener listener) throws LinphoneCoreException;
/**
* Returns true if echo calibration is recommended.

View file

@ -75,15 +75,6 @@ public interface LinphoneCoreListener {
*/
void dtmfReceived(LinphoneCore lc, LinphoneCall call, int dtmf);
/**
* Invoked when echo cancalation calibration is completed
* @param lc LinphoneCore
* @param status
* @param delay_ms echo delay
* @param data
*/
void ecCalibrationStatus(LinphoneCore lc,LinphoneCore.EcCalibratorStatus status, int delay_ms, Object data);
/**
* Report Notified message received for this identity.
* @param lc LinphoneCore
@ -243,5 +234,16 @@ public interface LinphoneCoreListener {
*/
void isComposingReceived(LinphoneCore lc, LinphoneChatRoom cr);
}
public interface LinphoneEchoCalibrationListener extends LinphoneCoreListener {
/**
* Invoked when echo cancalation calibration is completed
* @param lc LinphoneCore
* @param status
* @param delay_ms echo delay
* @param data
*/
void ecCalibrationStatus(LinphoneCore lc,LinphoneCore.EcCalibratorStatus status, int delay_ms, Object data);
}
}

View file

@ -24,6 +24,7 @@ import java.io.File;
import java.io.IOException;
import org.linphone.core.LinphoneCall.State;
import org.linphone.core.LinphoneCoreListener.LinphoneEchoCalibrationListener;
import org.linphone.mediastream.Log;
import org.linphone.mediastream.video.AndroidVideoWindowImpl;
import org.linphone.mediastream.video.capture.hwconf.Hacks;
@ -558,8 +559,8 @@ class LinphoneCoreImpl implements LinphoneCore {
public synchronized boolean isKeepAliveEnabled() {
return isKeepAliveEnabled(nativePtr);
}
public synchronized void startEchoCalibration(Object data) throws LinphoneCoreException {
startEchoCalibration(nativePtr, data);
public synchronized void startEchoCalibration(LinphoneEchoCalibrationListener listener) throws LinphoneCoreException {
startEchoCalibration(nativePtr, listener);
}
public synchronized Transports getSignalingTransportPorts() {