mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Merge branch 'mkirk/fix-unnecessary-session-changes'
This commit is contained in:
commit
914d2936a3
|
@ -145,7 +145,7 @@ struct AudioSource: Hashable {
|
|||
ensureProperAudioSession(call: call)
|
||||
|
||||
// It's importent to set preferred input *after* ensuring properAudioSession
|
||||
// because some sources are only valid for certain categories.
|
||||
// because some sources are only valid for certain category/option combinations.
|
||||
let session = AVAudioSession.sharedInstance()
|
||||
do {
|
||||
try session.setPreferredInput(audioSource?.portDescription)
|
||||
|
@ -161,6 +161,8 @@ struct AudioSource: Hashable {
|
|||
}
|
||||
|
||||
private func ensureProperAudioSession(call: SignalCall?) {
|
||||
AssertIsOnMainThread()
|
||||
|
||||
guard let call = call else {
|
||||
setAudioSession(category: AVAudioSessionCategoryPlayback,
|
||||
mode: AVAudioSessionModeDefault)
|
||||
|
@ -178,16 +180,22 @@ struct AudioSource: Hashable {
|
|||
setAudioSession(category: AVAudioSessionCategoryPlayAndRecord,
|
||||
mode: AVAudioSessionModeVideoChat,
|
||||
options: options)
|
||||
} else if call.isSpeakerphoneEnabled {
|
||||
// Ensure no bluetooth if user has specified speakerphone
|
||||
setAudioSession(category: AVAudioSessionCategoryPlayAndRecord,
|
||||
mode: AVAudioSessionModeVoiceChat,
|
||||
options: [.defaultToSpeaker])
|
||||
} else {
|
||||
setAudioSession(category: AVAudioSessionCategoryPlayAndRecord,
|
||||
mode: AVAudioSessionModeVoiceChat,
|
||||
options: [.allowBluetooth])
|
||||
}
|
||||
|
||||
let session = AVAudioSession.sharedInstance()
|
||||
do {
|
||||
if call.isSpeakerphoneEnabled {
|
||||
try session.overrideOutputAudioPort(.speaker)
|
||||
} else {
|
||||
try session.overrideOutputAudioPort(.none)
|
||||
}
|
||||
} catch {
|
||||
owsFail("\(TAG) failed overrideing output audio. isSpeakerPhoneEnabled: \(call.isSpeakerphoneEnabled)")
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Service action handlers
|
||||
|
|
Loading…
Reference in a new issue