keep speaker after pause if speaker was enabled

This commit is contained in:
Benjamin Reis 2017-07-06 14:10:18 +02:00
parent b2a3a23a20
commit 5a77092c77
4 changed files with 14 additions and 0 deletions

View file

@ -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;

View file

@ -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)) {

View file

@ -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");

View file

@ -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]];