From 220cd345f61755a69cb716c801dc4c2e21dfc873 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Fri, 14 Jul 2017 16:13:30 -0400 Subject: [PATCH] add comments // FREEBIE --- Signal/src/ViewControllers/CallViewController.swift | 2 +- Signal/src/call/CallAudioService.swift | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Signal/src/ViewControllers/CallViewController.swift b/Signal/src/ViewControllers/CallViewController.swift index 4fb6ab977..4035b2d8e 100644 --- a/Signal/src/ViewControllers/CallViewController.swift +++ b/Signal/src/ViewControllers/CallViewController.swift @@ -89,7 +89,7 @@ class CallViewController: UIViewController, CallObserver, CallServiceObserver, R // MARK: Audio Source var hasAlternateAudioSources: Bool { - Logger.info("\(TAG) available audio routes count: \(allAudioSources.count)") + Logger.info("\(TAG) available audio sources: \(allAudioSources)") // internal mic and speakerphone will be the first two, any more than one indicates e.g. an attached bluetooth device. // TODO is this sufficient? Are their devices w/ bluetooth but no external speaker? e.g. ipod? diff --git a/Signal/src/call/CallAudioService.swift b/Signal/src/call/CallAudioService.swift index 0b311338b..04ce81517 100644 --- a/Signal/src/call/CallAudioService.swift +++ b/Signal/src/call/CallAudioService.swift @@ -182,13 +182,18 @@ struct AudioSource: Hashable { setAudioSession(category: AVAudioSessionCategorySoloAmbient, mode: AVAudioSessionModeDefault) } else if call.hasLocalVideo { - // Don't allow bluetooth for local video if speakerphone has been explicitly chosen by the user. - let options: AVAudioSessionCategoryOptions = call.isSpeakerphoneEnabled ? [.defaultToSpeaker] : [.defaultToSpeaker, .allowBluetooth] - + // 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 + // does not include my linked bluetooth device setAudioSession(category: AVAudioSessionCategoryPlayAndRecord, mode: AVAudioSessionModeVideoChat, - options: options) + options: [.allowBluetooth]) } else { + // Apple Docs say that setting mode to AVAudioSessionModeVoiceChat has the + // side effect of setting options: .allowBluetooth, when I remove the (seemingly unnecessary) + // option, and inspect AVAudioSession.sharedInstance.categoryOptions == 0. And availableInputs + // does not include my linked bluetooth device setAudioSession(category: AVAudioSessionCategoryPlayAndRecord, mode: AVAudioSessionModeVoiceChat, options: [.allowBluetooth])