diff --git a/Classes/LinphoneCoreSettingsStore.m b/Classes/LinphoneCoreSettingsStore.m index 3c82e86..97ea78b 100644 --- a/Classes/LinphoneCoreSettingsStore.m +++ b/Classes/LinphoneCoreSettingsStore.m @@ -269,6 +269,9 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); LinphoneCore *lc = [LinphoneManager getLc]; LinphoneManager* lLinphoneMgr = [LinphoneManager instance]; LinphoneProxyConfig* proxyCfg = NULL; + + bool stoppedTimer = [lLinphoneMgr stopTimer]; + /* unregister before modifying any settings */ { linphone_core_get_default_proxy(lc, &proxyCfg); @@ -413,6 +416,11 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); linphone_address_destroy(linphoneAddress); } [[[LinphoneManager instance] fastAddressBook] reload]; + + + if (stoppedTimer) { + [lLinphoneMgr startTimer]; + } } + (int)validPort:(int)port { diff --git a/Classes/LinphoneManager.h b/Classes/LinphoneManager.h index b90e36f..64a8f3e 100644 --- a/Classes/LinphoneManager.h +++ b/Classes/LinphoneManager.h @@ -119,6 +119,8 @@ typedef struct _LinphoneManagerSounds { - (void)startLibLinphone; - (void)destroyLibLinphone; +- (bool)stopTimer; +- (bool)startTimer; - (BOOL)resignActive; - (void)becomeActive; - (BOOL)enterBackgroundMode; diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 9297622..9ba68ff 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -796,6 +796,27 @@ static LinphoneCoreVTable linphonec_vtable = { linphone_core_iterate(theLinphoneCore); } +- (bool)startTimer { + if (! mIterateTimer) { + mIterateTimer = [NSTimer scheduledTimerWithTimeInterval:0.02 + target:self + selector:@selector(iterate) + userInfo:nil + repeats:YES]; + return true; + } + return false; +} + +- (bool)stopTimer { + if (mIterateTimer) { + [mIterateTimer invalidate]; + mIterateTimer = nil; + return true; + } + return false; +} + - (void)startLibLinphone { if (theLinphoneCore != nil) { [LinphoneLogger logc:LinphoneLoggerLog format:"linphonecore is already created"]; @@ -856,11 +877,8 @@ static LinphoneCoreVTable linphonec_vtable = { [self setupNetworkReachabilityCallback]; // start scheduler - mIterateTimer = [NSTimer scheduledTimerWithTimeInterval:0.02 - target:self - selector:@selector(iterate) - userInfo:nil - repeats:YES]; + [self startTimer]; + //init audio session AVAudioSession *audioSession = [AVAudioSession sharedInstance]; BOOL bAudioInputAvailable= [audioSession inputIsAvailable]; @@ -931,7 +949,7 @@ static LinphoneCoreVTable linphonec_vtable = { } - (void)destroyLibLinphone { - [mIterateTimer invalidate]; + [self stopTimer]; //just in case [self removeCTCallCenterCb];