Merge branch 'charlesmchen/bluetoothAudio'

pull/1/head
Matthew Chen 7 years ago
commit 48a2005aa2

@ -3148,7 +3148,9 @@ typedef enum : NSUInteger {
OWSAssert(session.recordPermission == AVAudioSessionRecordPermissionGranted);
NSError *error;
[session setCategory:AVAudioSessionCategoryRecord error:&error];
[session setCategory:AVAudioSessionCategoryRecord
withOptions:AVAudioSessionCategoryOptionAllowBluetooth
error:&error];
if (error) {
DDLogError(@"%@ Couldn't configure audio session: %@", self.tag, error);
[self cancelVoiceMemo];

@ -105,7 +105,8 @@ import AVFoundation
options: .defaultToSpeaker)
} else {
setAudioSession(category: AVAudioSessionCategoryPlayAndRecord,
mode: AVAudioSessionModeVoiceChat)
mode: AVAudioSessionModeVoiceChat,
options: [.allowBluetooth])
}
}
@ -150,7 +151,7 @@ import AVFoundation
} else {
setAudioSession(category: AVAudioSessionCategoryPlayAndRecord,
mode: AVAudioSessionModeVoiceChat,
options: .mixWithOthers)
options: [.mixWithOthers, .allowBluetooth])
}
// HACK: Without this async, dialing sound only plays once. I don't really understand why. Does the audioSession
@ -299,6 +300,8 @@ import AVFoundation
private func setAudioSession(category: String,
mode: String? = nil,
options: AVAudioSessionCategoryOptions = AVAudioSessionCategoryOptions(rawValue: 0)) {
assert(Thread.isMainThread)
do {
if #available(iOS 10.0, *), let mode = mode {
try AVAudioSession.sharedInstance().setCategory(category, mode: mode, options: options)

Loading…
Cancel
Save