Uniform volume when ringing on speakerphone vs video

// FREEBIE
pull/1/head
Michael Kirk 8 years ago
parent a63a767bf2
commit 402d4157c8

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

@ -11,8 +11,7 @@ import WebRTC
* permission requested (and recording banner) before they even know they have an incoming call.
*
* By using the `useManualAudio` and `isAudioEnabled` attributes of the RTCAudioSession we can delay recording until
* it makes sense. However, the headers for RTCAudioSession are not exported by default, so we've vendored the header
* into our project. See "Libraries/WebRTC"
* it makes sense.
*/
class CallAudioSession {

Loading…
Cancel
Save