Prevent crash when toggling speaker out of call

This commit is contained in:
Christophe Deschamps 2022-03-22 18:00:53 +01:00
parent 64d08445b6
commit 1e45f7d58c

View file

@ -90,16 +90,16 @@ import linphonesw
}
static private func routeAudioTo( call: Call?, types: [AudioDeviceType]) {
let currentCall = call != nil ? call : core.currentCall != nil ? core.currentCall : core.calls[0]
if (call != nil || currentCall != nil) {
let callToUse = call != nil ? call : currentCall
applyAudioRouteChange(call: callToUse, types: types)
changeCaptureDeviceToMatchAudioRoute(call: callToUse, types: types)
} else {
applyAudioRouteChange(call: call, types: types)
changeCaptureDeviceToMatchAudioRoute(call: call, types: types)
}
let currentCall = call != nil ? call : core.currentCall != nil ? core.currentCall : (core.callsNb > 0 ? core.calls[0] : nil)
if (call != nil || currentCall != nil) {
let callToUse = call != nil ? call : currentCall
applyAudioRouteChange(call: callToUse, types: types)
changeCaptureDeviceToMatchAudioRoute(call: callToUse, types: types)
} else {
applyAudioRouteChange(call: call, types: types)
changeCaptureDeviceToMatchAudioRoute(call: call, types: types)
}
}
static func routeAudioToEarpiece(call: Call? = nil) {
routeAudioTo(call: call, types: [AudioDeviceType.Microphone]) // on iOS Earpiece = Microphone