|
|
|
@ -192,15 +192,13 @@ public class SimpleAudioReceiver: NSObject { |
|
|
|
do { |
|
|
|
// 确保正在写入状态 |
|
|
|
guard self._isWriting else { return } |
|
|
|
// 设置音频会话参数 |
|
|
|
try audioSession.setCategory(.playAndRecord, |
|
|
|
mode: .voiceChat, |
|
|
|
options: [.defaultToSpeaker, |
|
|
|
.mixWithOthers, |
|
|
|
.defaultToSpeaker, |
|
|
|
.allowBluetoothA2DP, |
|
|
|
.allowBluetooth]) |
|
|
|
try audioSession.overrideOutputAudioPort(.none) |
|
|
|
// 设置音频会话参数 |
|
|
|
try audioSession.setCategory(.playAndRecord, |
|
|
|
mode: .videoChat, |
|
|
|
options: [.allowBluetoothA2DP, // 允许蓝牙耳机,不占用hfp链路 |
|
|
|
.mixWithOthers, |
|
|
|
.defaultToSpeaker]) // 添加音频优先级控制 |
|
|
|
|
|
|
|
try audioSession.setActive(true) |
|
|
|
try micCapture.startCapture() |
|
|
|
try micCapture.audioDataHandler = { data in |
|
|
|
|