mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Voice chat fixes
This commit is contained in:
@@ -174,7 +174,19 @@ public final class ManagedAudioSession {
|
||||
private var currentTypeAndOutputMode: (ManagedAudioSessionType, AudioSessionOutputMode)?
|
||||
private var deactivateTimer: SwiftSignalKit.Timer?
|
||||
|
||||
private var isHeadsetPluggedInValue = false
|
||||
private let isHeadsetPluggedInSync = Atomic<Bool>(value: false)
|
||||
private var isHeadsetPluggedInValue = false {
|
||||
didSet {
|
||||
if self.isHeadsetPluggedInValue != oldValue {
|
||||
let _ = self.isHeadsetPluggedInSync.swap(self.isHeadsetPluggedInValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public func getIsHeadsetPluggedIn() -> Bool {
|
||||
return self.isHeadsetPluggedInSync.with { $0 }
|
||||
}
|
||||
|
||||
private let outputsToHeadphonesSubscribers = Bag<(Bool) -> Void>()
|
||||
|
||||
private var availableOutputsValue: [AudioSessionOutput] = []
|
||||
@@ -770,14 +782,17 @@ public final class ManagedAudioSession {
|
||||
if let routes = AVAudioSession.sharedInstance().availableInputs {
|
||||
var alreadySet = false
|
||||
if self.isHeadsetPluggedInValue {
|
||||
loop: for route in routes {
|
||||
switch route.portType {
|
||||
case .headphones, .bluetoothA2DP, .bluetoothHFP:
|
||||
let _ = try? AVAudioSession.sharedInstance().setPreferredInput(route)
|
||||
alreadySet = true
|
||||
break loop
|
||||
default:
|
||||
break
|
||||
if case .voiceCall = updatedType, case .custom(.builtin) = outputMode {
|
||||
} else {
|
||||
loop: for route in routes {
|
||||
switch route.portType {
|
||||
case .headphones, .bluetoothA2DP, .bluetoothHFP:
|
||||
let _ = try? AVAudioSession.sharedInstance().setPreferredInput(route)
|
||||
alreadySet = true
|
||||
break loop
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user