From e0b7e4087c0c967810f091c3be75c19462a8b148 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Sun, 15 Jan 2023 23:10:10 +0400 Subject: [PATCH] Fix video call headphones --- .../TelegramAudio/Sources/ManagedAudioSession.swift | 10 +++++++++- .../TelegramCallsUI/Sources/CallControllerNode.swift | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/submodules/TelegramAudio/Sources/ManagedAudioSession.swift b/submodules/TelegramAudio/Sources/ManagedAudioSession.swift index eb42a04996..085e2628e6 100644 --- a/submodules/TelegramAudio/Sources/ManagedAudioSession.swift +++ b/submodules/TelegramAudio/Sources/ManagedAudioSession.swift @@ -58,6 +58,7 @@ private func nativeCategoryForType(_ type: ManagedAudioSessionType, headphones: public enum AudioSessionPortType { case generic case bluetooth + case wired } public struct AudioSessionPort: Equatable { @@ -77,7 +78,14 @@ private let bluetoothPortTypes = Set([.bluetoothA2DP, .blue private extension AudioSessionOutput { init(description: AVAudioSessionPortDescription) { - self = .port(AudioSessionPort(uid: description.uid, name: description.portName, type: bluetoothPortTypes.contains(description.portType) ? .bluetooth : .generic)) + var type: AudioSessionPortType = .generic + if bluetoothPortTypes.contains(description.portType) { + type = .bluetooth + } else if description.uid == "Wired Headphones" || description.uid == "Wired Microphone" { + type = .wired + } + + self = .port(AudioSessionPort(uid: description.uid, name: description.portName, type: type)) } } diff --git a/submodules/TelegramCallsUI/Sources/CallControllerNode.swift b/submodules/TelegramCallsUI/Sources/CallControllerNode.swift index b612a9711e..e1818f74e9 100644 --- a/submodules/TelegramCallsUI/Sources/CallControllerNode.swift +++ b/submodules/TelegramCallsUI/Sources/CallControllerNode.swift @@ -825,7 +825,7 @@ final class CallControllerNode: ViewControllerTracingNode, CallControllerNodePro switch currentOutput { case .headphones, .speaker: break - case let .port(port) where port.type == .bluetooth: + case let .port(port) where port.type == .bluetooth || port.type == .wired: break default: self.setCurrentAudioOutput?(.speaker)