more cleanup and commenting

// FREEBIE
pull/1/head
Michael Kirk 8 years ago
parent 03f1bbca62
commit b495b23420

@ -354,13 +354,20 @@ class CallViewController: UIViewController, CallObserver, CallServiceObserver, R
func didChangeAudioSession() { func didChangeAudioSession() {
AssertIsOnMainThread() AssertIsOnMainThread()
// TODO unnecessary?
// Which sources are available depends on the state of your Session.
// When the audio session is not yet in PlayAndRecord none are available
// Then if we're in speakerphone, bluetooth isn't available.
// So we acrew all possible audio sources in a set, and that list lives as longs as the CallViewController
// The downside of this is that if you e.g. unpair your bluetooth mid call, it will still appear as an option
// until your next call.
// FIXME: There's got to be a better way, but this is where I landed after a bit of work, and seems to work
// pretty well in practrice.
let availableInputs = callUIAdapter.audioService.availableInputs let availableInputs = callUIAdapter.audioService.availableInputs
self.allAudioSources.formUnion(availableInputs) self.allAudioSources.formUnion(availableInputs)
} }
func presentAudioSourcePicker() { func presentAudioSourcePicker() {
Logger.info("\(TAG) in \(#function)")
AssertIsOnMainThread() AssertIsOnMainThread()
let actionSheetController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet) let actionSheetController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)

@ -407,16 +407,20 @@ struct AudioSource: Hashable {
} }
func currentAudioSource(call: SignalCall) -> AudioSource? { func currentAudioSource(call: SignalCall) -> AudioSource? {
if call.isSpeakerphoneEnabled { if let audioSource = call.audioSource {
return AudioSource.builtInSpeaker return audioSource
} else { }
let session = AVAudioSession.sharedInstance()
guard let portDescription = session.currentRoute.inputs.first else {
return nil
}
return AudioSource(portDescription: portDescription) // Before the user has specified an audio source on the call, we rely on the existing
// system state to determine the current audio source.
// If a bluetooth is connected, this will be bluetooth, otherwise
// this will be the receiver.
let session = AVAudioSession.sharedInstance()
guard let portDescription = session.currentRoute.inputs.first else {
return nil
} }
return AudioSource(portDescription: portDescription)
} }
public func setPreferredInput(call: SignalCall, audioSource: AudioSource?) { public func setPreferredInput(call: SignalCall, audioSource: AudioSource?) {

Loading…
Cancel
Save