audio session config test

This commit is contained in:
TrueZhuanjia committed 2025-10-29 00:16:24 +08:00
1 parent 071e2a764a
commit a9f4db52b5
2 files changed
+4 -3

No files matched your search

+1 -1
View File
@@ -186,7 +186,7 @@ public class MicHandler: NSObject {
private func configureSession() throws { private func configureSession() throws {
let session = AVAudioSession.sharedInstance() let session = AVAudioSession.sharedInstance()
let bluetoothAudioOption = self.useBuiltinMic ? AVAudioSession.CategoryOptions.allowBluetoothA2DP : AVAudioSession.CategoryOptions.allowBluetooth let bluetoothAudioOption = self.useBuiltinMic ? AVAudioSession.CategoryOptions.allowBluetoothA2DP : AVAudioSession.CategoryOptions.allowBluetooth
try session.setCategory(.playAndRecord, mode: .videoRecording, options: [.mixWithOthers, .defaultToSpeaker, bluetoothAudioOption]) try session.setCategory(.playAndRecord, mode: .default, options: [.mixWithOthers, .defaultToSpeaker, bluetoothAudioOption])
if #available(iOS 13.0, *) { if #available(iOS 13.0, *) {
try session.setAllowHapticsAndSystemSoundsDuringRecording(true) try session.setAllowHapticsAndSystemSoundsDuringRecording(true)
} }
+3 -2
View File
@@ -292,8 +292,9 @@ int ArInit(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusConfig, v
bool useBluetoothD2P = tempSettings.useBuiltinMic || !tempSettings.redirectMic; bool useBluetoothD2P = tempSettings.useBuiltinMic || !tempSettings.redirectMic;
AVAudioSessionCategoryOptions bluetoothAudioOption = useBluetoothD2P ? AVAudioSessionCategoryOptionAllowBluetoothA2DP : AVAudioSessionCategoryOptionAllowBluetooth; AVAudioSessionCategoryOptions bluetoothAudioOption = useBluetoothD2P ? AVAudioSessionCategoryOptionAllowBluetoothA2DP : AVAudioSessionCategoryOptionAllowBluetooth;
AVAudioSession *session = [AVAudioSession sharedInstance]; AVAudioSession *session = [AVAudioSession sharedInstance];
[session setCategory:AVAudioSessionCategoryPlayAndRecord [session setCategory:tempSettings.redirectMic ? AVAudioSessionCategoryPlayAndRecord : AVAudioSessionCategoryPlayback
withOptions:AVAudioSessionCategoryOptionMixWithOthers|AVAudioSessionCategoryOptionDefaultToSpeaker|bluetoothAudioOption mode:AVAudioSessionModeDefault
options:AVAudioSessionCategoryOptionMixWithOthers|AVAudioSessionCategoryOptionDefaultToSpeaker|bluetoothAudioOption
error:nil]; error:nil];
[session setActive:YES error:nil]; [session setActive:YES error:nil];