|
|
|
@ -188,7 +188,10 @@ struct AudioSource: Hashable {
|
|
|
|
|
// SoloAmbient plays through speaker, but respects silent switch
|
|
|
|
|
setAudioSession(category: AVAudioSessionCategorySoloAmbient,
|
|
|
|
|
mode: AVAudioSessionModeDefault)
|
|
|
|
|
} else if call.hasLocalVideo {
|
|
|
|
|
} else if call.state == .connected, call.hasLocalVideo {
|
|
|
|
|
// Because ModeVideoChat affects gain, we don't want to apply it until the call is connected.
|
|
|
|
|
// otherwise sounds like ringing will be extra loud for video vs. speakerphone
|
|
|
|
|
|
|
|
|
|
// Apple Docs say that setting mode to AVAudioSessionModeVideoChat has the
|
|
|
|
|
// side effect of setting options: .allowBluetooth, when I remove the (seemingly unnecessary)
|
|
|
|
|
// option, and inspect AVAudioSession.sharedInstance.categoryOptions == 0. And availableInputs
|
|
|
|
@ -216,9 +219,14 @@ struct AudioSource: Hashable {
|
|
|
|
|
try session.setPreferredInput(call.audioSource?.portDescription)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if call.isSpeakerphoneEnabled {
|
|
|
|
|
if call.isSpeakerphoneEnabled || (call.hasLocalVideo && call.state != .connected) {
|
|
|
|
|
// We want consistent ringer-volume between speaker-phone and video chat.
|
|
|
|
|
// But because using VideoChat mode has noticeably higher output gain, we treat
|
|
|
|
|
// video chat like speakerphone mode until the call is connected.
|
|
|
|
|
Logger.verbose("\(TAG) enabling speakerphone overrideOutputAudioPort(.speaker)")
|
|
|
|
|
try session.overrideOutputAudioPort(.speaker)
|
|
|
|
|
} else {
|
|
|
|
|
Logger.verbose("\(TAG) disabling spearkerphone overrideOutputAudioPort(.none) ")
|
|
|
|
|
try session.overrideOutputAudioPort(.none)
|
|
|
|
|
}
|
|
|
|
|
} catch {
|
|
|
|
|