Skip to content

Commit fa00c05

Browse files
committed
fix: respect external USB-C microphone for voice message recording
overrideOutputAudioPort(.speaker) forces both output and input to built-in devices, ignoring external USB-C microphones (e.g. wireless mic receivers) that the user selected in iOS Settings. After the override, check availableInputs for non-built-in, non-bluetooth, non-headphone input devices and restore them as preferred input. This preserves existing behavior when no external device is connected. Fixes: voice messages ignore USB-C microphone on iOS 26+
1 parent 63a37c5 commit fa00c05

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

submodules/TelegramAudio/Sources/ManagedAudioSession.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,17 @@ public final class ManagedAudioSessionImpl: NSObject, ManagedAudioSession {
10651065
switch updatedType {
10661066
case .record(false, _, _):
10671067
try AVAudioSession.sharedInstance().overrideOutputAudioPort(.speaker)
1068+
// overrideOutputAudioPort(.speaker) forces both output AND input
1069+
// to built-in devices. If an external input device (e.g. USB-C
1070+
// microphone) is connected, restore it as the preferred input.
1071+
if let routes = AVAudioSession.sharedInstance().availableInputs {
1072+
for route in routes {
1073+
if route.portType != .builtInMic && !bluetoothPortTypes.contains(route.portType) && route.portType != .headphones {
1074+
let _ = try? AVAudioSession.sharedInstance().setPreferredInput(route)
1075+
break
1076+
}
1077+
}
1078+
}
10681079
case .voiceCall, .playWithPossiblePortOverride, .record(true, _, _):
10691080
try AVAudioSession.sharedInstance().overrideOutputAudioPort(.none)
10701081
if let routes = AVAudioSession.sharedInstance().availableInputs {

0 commit comments

Comments
 (0)