Commit e07b714c authored by Mickaël Turnel's avatar Mickaël Turnel

Remove async network task if core is stopping

parent e540de3c
......@@ -6257,6 +6257,9 @@ void _linphone_core_uninit(LinphoneCore *lc)
lc->chat_rooms = bctbx_list_free_with_data(lc->chat_rooms, (bctbx_list_free_func)linphone_chat_room_unref);
linphone_core_set_state(lc,LinphoneGlobalShutdown,"Shutting down");
getPlatformHelpers(lc)->onLinphoneCoreStop();
#ifdef VIDEO_ENABLED
if (lc->previewstream!=NULL){
video_preview_stop(lc->previewstream);
......
......@@ -61,6 +61,7 @@ public:
void setHttpProxy (string host, int port) override;
void onLinphoneCoreStart (bool monitoringEnabled) override;
void onLinphoneCoreStop () override;
void _setPreviewVideoWindow(jobject window);
void _setVideoWindow(jobject window);
......@@ -88,6 +89,7 @@ private:
jmethodID mSetNativePreviewVideoWindowId;
jmethodID mUpdateNetworkReachabilityId;
jmethodID mOnLinphoneCoreStartId;
jmethodID mOnLinphoneCoreStopId;
jmethodID mOnWifiOnlyEnabledId;
jobject mPreviewVideoWindow;
jobject mVideoWindow;
......@@ -141,6 +143,7 @@ AndroidPlatformHelpers::AndroidPlatformHelpers (LinphoneCore *lc, void *systemCo
mSetNativePreviewVideoWindowId = getMethodId(env, klass, "setVideoPreviewView", "(Ljava/lang/Object;)V");
mUpdateNetworkReachabilityId = getMethodId(env, klass, "updateNetworkReachability", "()V");
mOnLinphoneCoreStartId = getMethodId(env, klass, "onLinphoneCoreStart", "(Z)V");
mOnLinphoneCoreStopId = getMethodId(env, klass, "onLinphoneCoreStop", "()V");
mOnWifiOnlyEnabledId = getMethodId(env, klass, "onWifiOnlyEnabled", "(Z)V");
jobject pm = env->CallObjectMethod(mJavaHelper, mGetPowerManagerId);
......@@ -340,6 +343,13 @@ void AndroidPlatformHelpers::onLinphoneCoreStart(bool monitoringEnabled) {
}
}
void AndroidPlatformHelpers::onLinphoneCoreStop() {
JNIEnv *env = ms_get_jni_env();
if (env && mJavaHelper) {
env->CallVoidMethod(mJavaHelper, mOnLinphoneCoreStopId);
}
}
// -----------------------------------------------------------------------------
void AndroidPlatformHelpers::_setPreviewVideoWindow(jobject window) {
......
......@@ -71,6 +71,7 @@ public:
void setNetworkReachable (bool reachable) override {}
void onLinphoneCoreStart (bool monitoringEnabled) override {}
void onLinphoneCoreStop () override {}
private:
void bgTaskTimeout ();
......
......@@ -129,6 +129,8 @@ void GenericPlatformHelpers::onLinphoneCoreStart (bool monitoringEnabled) {
monitorTimerExpired(this, 0);
}
void GenericPlatformHelpers::onLinphoneCoreStop () {}
int GenericPlatformHelpers::monitorTimerExpired (void *data, unsigned int revents) {
GenericPlatformHelpers *helper = static_cast<GenericPlatformHelpers *>(data);
......
......@@ -69,6 +69,7 @@ public:
virtual void setNetworkReachable (bool reachable) = 0;
virtual void onLinphoneCoreStart (bool monitoringEnabled) = 0;
virtual void onLinphoneCoreStop () = 0;
protected:
inline explicit PlatformHelpers (LinphoneCore *lc) : mCore(lc) {}
......@@ -111,6 +112,7 @@ public:
void setNetworkReachable (bool reachable) override;
void onLinphoneCoreStart (bool monitoringEnabled) override;
void onLinphoneCoreStop () override;
private:
static int monitorTimerExpired (void *data, unsigned int revents);
......
......@@ -163,6 +163,11 @@ public class AndroidPlatformHelper {
postNetworkUpdateRunner();
}
public synchronized void onLinphoneCoreStop() {
mNativePtr = 0;
mMainHandler.removeCallbacks(mNetworkUpdateRunner);
}
public void onWifiOnlyEnabled(boolean enabled) {
mWifiOnly = enabled;
postNetworkUpdateRunner();
......@@ -337,7 +342,7 @@ public class AndroidPlatformHelper {
}
}
public void setVideoPreviewView(Object view) {
public synchronized void setVideoPreviewView(Object view) {
if (!(view instanceof TextureView)) {
throw new RuntimeException("Preview window id is not an instance of TextureView. " +
"Please update your UI layer so that the preview video view is a TextureView (or an instance of it)" +
......@@ -375,7 +380,7 @@ public class AndroidPlatformHelper {
}
}
public void setVideoRenderingView(Object view) {
public synchronized void setVideoRenderingView(Object view) {
if (!(view instanceof TextureView)) {
throw new RuntimeException("Rendering window id is not an instance of TextureView." +
"Please update your UI layer so that the video rendering view is a TextureView (or an instance of it)" +
......@@ -419,8 +424,11 @@ public class AndroidPlatformHelper {
mMainHandler.post(mNetworkUpdateRunner);
}
public void updateNetworkReachability() {
public synchronized void updateNetworkReachability() {
if (mConnectivityManager == null) return;
if (mNativePtr == 0) {
return;
}
boolean usingHttpProxyBefore = mUsingHttpProxy;
boolean connected = false;
......
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