From 4c23b5e23f04d3e8525c5ffcc7ccd631c643d65b Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Wed, 18 Jan 2017 11:54:13 -0500 Subject: [PATCH] Remove dependency on AppAudioManager Implement speakerphone toggle directly. Previously we were using AppAudioManager for several things, but this is that last lingering bit. Much of the AppAudioManager code is based on RedPhone calling, so by removing the dependency we pave the way to throw that code away. // FREEBIE --- Signal/src/call/CallAudioService.swift | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/Signal/src/call/CallAudioService.swift b/Signal/src/call/CallAudioService.swift index f29181374..7ee45fe64 100644 --- a/Signal/src/call/CallAudioService.swift +++ b/Signal/src/call/CallAudioService.swift @@ -7,7 +7,6 @@ import Foundation @objc class CallAudioService: NSObject { private let TAG = "[CallAudioService]" private var vibrateTimer: Timer? - private let audioManager = AppAudioManager.sharedInstance() private let soundPlayer = JSQSystemSoundPlayer.shared()! enum SoundFilenames: String { @@ -98,16 +97,11 @@ import Foundation } private func handleUpdatedSpeakerphone() { - // TODO -// let category = AVAudioSession.sharedInstance().getCategory() -// if isSpeakerphoneEnabled { -// AVAudioSession.sharedInstance().setCategory(category, option: AVAudioSessionCategoryOptionDefaultToSpeaker) -// } else { - // Will this disable speaker? -// AVAudioSession.sharedInstance().setCategory(category) -// } - - audioManager.toggleSpeakerPhone(isEnabled: isSpeakerphoneEnabled) + if isSpeakerphoneEnabled { + setAudioSession(category: AVAudioSessionCategoryPlayAndRecord, options: .defaultToSpeaker) + } else { + setAudioSession(category: AVAudioSessionCategoryPlayAndRecord) + } } // MARK: Helpers