Skip to content

Commit

Permalink
Fixes #3136 - Stop manually configuring ElementCall's AudioSession
Browse files Browse the repository at this point in the history
- CallKit decides what action to to take when pressing the hardware lock button based on where the audio is routed to. Using the speaker will make it lock the phone while using the headset will make it end the call.
- Before the introduction of CallKit we had to manually setup the AudioSession to keep the audio live in the background. This is now clashing with CallKit making it bevelie the audio is not routed to the speaker and causing the call be terminated when pressing the lock button.
  • Loading branch information
stefanceriu committed Aug 8, 2024
1 parent 534860b commit 7818fa6
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions ElementX/Sources/Services/ElementCall/ElementCallService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,6 @@ class ElementCallService: NSObject, ElementCallServiceProtocol, PKPushRegistryDe
} catch {
MXLog.error("Failed requesting start call action with error: \(error)")
}

do { // Setup the audio session even if setting up CallKit failed, ElementCall **is** running at this point
try AVAudioSession.sharedInstance().setCategory(.playAndRecord, mode: .videoChat, options: [])
try AVAudioSession.sharedInstance().setActive(true, options: .notifyOthersOnDeactivation)
} catch {
MXLog.error("Failed setting up audio session with error: \(error)")
}
}

func tearDownCallSession() {
Expand Down Expand Up @@ -181,6 +174,14 @@ class ElementCallService: NSObject, ElementCallServiceProtocol, PKPushRegistryDe

// MARK: - CXProviderDelegate

func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession) {
MXLog.info("Call provider did activate audio session")
}

func provider(_ provider: CXProvider, didDeactivate audioSession: AVAudioSession) {
MXLog.info("Call provider did deactivate audio session")
}

func providerDidReset(_ provider: CXProvider) {
MXLog.info("Call provider did reset: \(provider)")
}
Expand Down

0 comments on commit 7818fa6

Please sign in to comment.