mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Ensure audio session is default after call is terminated.
Previously, we were enabling PlayAndRecord when a call ended due to the CallService observer's "updateVideoTrack" callbacks. // FREEBIE
This commit is contained in:
parent
6eb1951ee6
commit
8dfe06e3f2
4 changed files with 22 additions and 1 deletions
|
@ -90,6 +90,13 @@
|
|||
NSString *_Nullable voipToken = [preferences getVoipToken];
|
||||
[debugSection addItem:[OWSTableItem labelItemWithText:[NSString stringWithFormat:@"Push Token: %@", pushToken ?: @"None" ]]];
|
||||
[debugSection addItem:[OWSTableItem labelItemWithText:[NSString stringWithFormat:@"VOIP Token: %@", voipToken ?: @"None" ]]];
|
||||
|
||||
// Strip prefix from category, otherwise it's too long to fit into cell on a small device.
|
||||
NSString *audioCategory =
|
||||
[AVAudioSession.sharedInstance.category stringByReplacingOccurrencesOfString:@"AVAudioSessionCategory"
|
||||
withString:@""];
|
||||
[debugSection
|
||||
addItem:[OWSTableItem labelItemWithText:[NSString stringWithFormat:@"Audio Category: %@", audioCategory]]];
|
||||
#endif
|
||||
|
||||
self.contents = contents;
|
||||
|
|
|
@ -159,6 +159,7 @@ protocol CallAudioServiceDelegate: class {
|
|||
|
||||
super.init()
|
||||
|
||||
// This fails when someone toggles iOS Call Integration
|
||||
SwiftSingletons.register(self)
|
||||
|
||||
// Configure audio session so we don't prompt user with Record permission until call is connected.
|
||||
|
@ -242,7 +243,8 @@ protocol CallAudioServiceDelegate: class {
|
|||
private func ensureProperAudioSession(call: SignalCall?) {
|
||||
AssertIsOnMainThread()
|
||||
|
||||
guard let call = call else {
|
||||
guard let call = call, !call.isTerminated else {
|
||||
// Revert to default audio
|
||||
setAudioSession(category: AVAudioSessionCategorySoloAmbient,
|
||||
mode: AVAudioSessionModeDefault)
|
||||
return
|
||||
|
|
|
@ -1507,6 +1507,9 @@ protocol CallServiceObserver: class {
|
|||
Logger.info("\(self.logTag) clearing pendingIceUpdateMessages")
|
||||
self.pendingIceUpdateMessages = []
|
||||
self.fulfillCallConnectedPromise = nil
|
||||
|
||||
// In case we're still waiting on this promise somewhere, we need to reject it to avoid a memory leak.
|
||||
// There is no harm in rejecting a previously fulfilled promise.
|
||||
if let rejectCallConnectedPromise = self.rejectCallConnectedPromise {
|
||||
rejectCallConnectedPromise(CallError.obsoleteCall(description: "Terminating call"))
|
||||
}
|
||||
|
|
|
@ -43,6 +43,15 @@ protocol CallObserver: class {
|
|||
var observers = [Weak<CallObserver>]()
|
||||
let remotePhoneNumber: String
|
||||
|
||||
var isTerminated: Bool {
|
||||
switch state {
|
||||
case .localFailure, .localHangup, .remoteHangup, .remoteBusy:
|
||||
return true
|
||||
case .idle, .dialing, .answering, .remoteRinging, .localRinging, .connected:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// Signal Service identifier for this Call. Used to coordinate the call across remote clients.
|
||||
let signalingId: UInt64
|
||||
|
||||
|
|
Loading…
Reference in a new issue