From 5a77092c778abdf41aeea7411067986ae728ccc5 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Thu, 6 Jul 2017 14:10:18 +0200 Subject: [PATCH] keep speaker after pause if speaker was enabled --- Classes/LinphoneManager.h | 1 + Classes/LinphoneManager.m | 10 ++++++++++ Classes/LinphoneUI/UIPauseButton.m | 2 ++ Classes/ProviderDelegate.m | 1 + 4 files changed, 14 insertions(+) diff --git a/Classes/LinphoneManager.h b/Classes/LinphoneManager.h index 411f60f25..adba17596 100644 --- a/Classes/LinphoneManager.h +++ b/Classes/LinphoneManager.h @@ -210,6 +210,7 @@ typedef struct _LinphoneManagerSounds { @property(nonatomic, strong) NSData *pushNotificationToken; @property (readonly) LinphoneManagerSounds sounds; @property (readonly) NSMutableArray *logs; +@property (nonatomic, assign) BOOL speakerBeforePause; @property (nonatomic, assign) BOOL speakerEnabled; @property (nonatomic, assign) BOOL bluetoothAvailable; @property (nonatomic, assign) BOOL bluetoothEnabled; diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 55c4357fc..08c6f12f4 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -252,6 +252,7 @@ struct codec_name_pref_table codec_pref_table[] = {{"speex", 8000, "speex_8k_pre _pushDict = [[NSMutableDictionary alloc] init]; _database = NULL; _speakerEnabled = FALSE; + _speakerBeforePause = FALSE; _bluetoothEnabled = FALSE; _conf = FALSE; _fileTransferDelegates = [[NSMutableArray alloc] init]; @@ -967,6 +968,13 @@ static void linphone_iphone_display_status(struct _LinphoneCore *lc, const char speaker_already_enabled = TRUE; } } + if (state == LinphoneCallStreamsRunning) { + if (_speakerBeforePause) { + _speakerBeforePause = FALSE; + [self setSpeakerEnabled:TRUE]; + speaker_already_enabled = TRUE; + } + } if (state == LinphoneCallConnected && !mCallCenter) { /*only register CT call center CB for connected call*/ @@ -2481,6 +2489,7 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) { LinphoneCall *c = linphone_core_get_current_call(theLinphoneCore); LOGI(@"Sound interruption detected!"); if (c && linphone_call_get_state(c) == LinphoneCallStreamsRunning) { + _speakerBeforePause = _speakerEnabled; linphone_call_pause(c); } } @@ -3092,6 +3101,7 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) { if ([ct currentCalls] != nil) { if (call) { LOGI(@"Pausing SIP call because GSM call"); + _speakerBeforePause = _speakerEnabled; linphone_call_pause(call); [self startCallPausedLongRunningTask]; } else if (linphone_core_is_in_conference(theLinphoneCore)) { diff --git a/Classes/LinphoneUI/UIPauseButton.m b/Classes/LinphoneUI/UIPauseButton.m index b7c7ff508..26778bc13 100644 --- a/Classes/LinphoneUI/UIPauseButton.m +++ b/Classes/LinphoneUI/UIPauseButton.m @@ -82,6 +82,7 @@ switch (type) { case UIPauseButtonType_Call: { if (call != nil) { + LinphoneManager.instance.speakerBeforePause = LinphoneManager.instance.speakerEnabled; linphone_call_pause(call); } else { LOGW(@"Cannot toggle pause buttton, because no current call"); @@ -98,6 +99,7 @@ case UIPauseButtonType_CurrentCall: { LinphoneCall *currentCall = [UIPauseButton getCall]; if (currentCall != nil) { + LinphoneManager.instance.speakerBeforePause = LinphoneManager.instance.speakerEnabled; linphone_call_pause(currentCall); } else { LOGW(@"Cannot toggle pause buttton, because no current call"); diff --git a/Classes/ProviderDelegate.m b/Classes/ProviderDelegate.m index 83811eecb..de3f1ffa1 100644 --- a/Classes/ProviderDelegate.m +++ b/Classes/ProviderDelegate.m @@ -171,6 +171,7 @@ LinphoneCall *call = [LinphoneManager.instance callByCallId:callID]; if (call) { if (action.isOnHold) { + LinphoneManager.instance.speakerBeforePause = LinphoneManager.instance.speakerEnabled; linphone_call_pause((LinphoneCall *)call); } else { [self configAudioSession:[AVAudioSession sharedInstance]];