Fix video call headphones

This commit is contained in:
Ali 2023-01-15 23:10:10 +04:00
parent 1af7d86c0c
commit e0b7e4087c
2 changed files with 10 additions and 2 deletions

View File

@ -58,6 +58,7 @@ private func nativeCategoryForType(_ type: ManagedAudioSessionType, headphones:
public enum AudioSessionPortType { public enum AudioSessionPortType {
case generic case generic
case bluetooth case bluetooth
case wired
} }
public struct AudioSessionPort: Equatable { public struct AudioSessionPort: Equatable {
@ -77,7 +78,14 @@ private let bluetoothPortTypes = Set<AVAudioSession.Port>([.bluetoothA2DP, .blue
private extension AudioSessionOutput { private extension AudioSessionOutput {
init(description: AVAudioSessionPortDescription) { 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))
} }
} }

View File

@ -825,7 +825,7 @@ final class CallControllerNode: ViewControllerTracingNode, CallControllerNodePro
switch currentOutput { switch currentOutput {
case .headphones, .speaker: case .headphones, .speaker:
break break
case let .port(port) where port.type == .bluetooth: case let .port(port) where port.type == .bluetooth || port.type == .wired:
break break
default: default:
self.setCurrentAudioOutput?(.speaker) self.setCurrentAudioOutput?(.speaker)