change defaults to support voice isolation
This commit is contained in:
@@ -79,15 +79,39 @@ public class SwiftLiveKitPlugin: NSObject, FlutterPlugin {
|
||||
print("[LiveKit] Configuring mode: ", configuration.mode)
|
||||
}
|
||||
|
||||
let session = RTCAudioSession.sharedInstance()
|
||||
session.lockForConfiguration()
|
||||
// get `RTCAudioSession` and lock
|
||||
let rtcSession = RTCAudioSession.sharedInstance()
|
||||
rtcSession.lockForConfiguration()
|
||||
|
||||
var isLocked: Bool = true
|
||||
let unlock = {
|
||||
guard isLocked else {
|
||||
print("[LiveKit] not locked, ignoring unlock")
|
||||
return
|
||||
}
|
||||
rtcSession.unlockForConfiguration()
|
||||
isLocked = false
|
||||
}
|
||||
|
||||
// always `unlock()` when exiting scope, calling multiple times has no side-effect
|
||||
defer {
|
||||
session.unlockForConfiguration()
|
||||
unlock()
|
||||
}
|
||||
|
||||
do {
|
||||
try session.setConfiguration(configuration, active: true)
|
||||
print("[LiveKit] Configure success")
|
||||
try rtcSession.setConfiguration(configuration, active: true)
|
||||
// unlock here before configuring `AVAudioSession`
|
||||
// unlock()
|
||||
print("[LiveKit] RTCAudioSession Configure success")
|
||||
|
||||
// also configure longFormAudio
|
||||
// let avSession = AVAudioSession.sharedInstance()
|
||||
// try avSession.setCategory(AVAudioSession.Category(rawValue: configuration.category),
|
||||
// mode: AVAudioSession.Mode(rawValue: configuration.mode),
|
||||
// policy: .default,
|
||||
// options: configuration.categoryOptions)
|
||||
// print("[LiveKit] AVAudioSession Configure success")
|
||||
|
||||
result(true)
|
||||
} catch let error {
|
||||
print("[LiveKit] Configure audio error: ", error)
|
||||
|
||||
Reference in New Issue
Block a user