@ -63,7 +63,8 @@ import Foundation
mode : AVAudioSessionModeVoiceChat ,
options : . defaultToSpeaker )
} else {
setAudioSession ( category : AVAudioSessionCategoryPlayAndRecord )
setAudioSession ( category : AVAudioSessionCategoryPlayAndRecord ,
mode : AVAudioSessionModeVoiceChat )
}
}
@ -185,28 +186,20 @@ import Foundation
}
private func setAudioSession ( category : String ,
mode : String ,
options : AVAudioSessionCategoryOptions ) {
mode : String ? = nil ,
options : AVAudioSessionCategoryOptions = AVAudioSessionCategoryOptions ( rawValue : 0 ) ) {
do {
if #available ( iOS 10.0 , * ) {
try
AVAudioSession . sharedInstance ( ) . setCategory ( category , mode : mode , options : options )
if #available ( iOS 10.0 , * ) , let mode = mode {
try AVAudioSession . sharedInstance ( ) . setCategory ( category , mode : mode , options : options )
Logger . debug ( " \( self . TAG ) set category: \( category ) mode: \( mode ) options: \( options ) " )
} else {
try
AVAudioSession . sharedInstance ( ) . setCategory ( category , with : options )
}
try AVAudioSession . sharedInstance ( ) . setCategory ( category , with : options )
Logger . debug ( " \( self . TAG ) set category: \( category ) options: \( options ) " )
}
} catch {
let message = " \( self . TAG ) in \( #function ) failed to set category: \( category ) with error: \( error ) "
assertionFailure ( message )
Logger . error ( message )
}
}
private func setAudioSession ( category : String ) {
// F I X M E W h y t h i s d e f a u l t m o d e ? I t d o e s n ' t w o r k w i t h e . g . " S o l o A m b i e n t " , c a u s i n g ` A V A u d i o S e s s i o n . s h a r e d I n s t a n c e ( ) . s e t C a t e g o r y ( c a t e g o r y , m o d e : m o d e , o p t i o n s : o p t i o n s ) ` t o e r r
setAudioSession ( category : category ,
mode : AVAudioSessionModeVoiceChat ,
options : AVAudioSessionCategoryOptions ( rawValue : 0 ) )
}
}