refactor audio engine init to Connection.m

This commit is contained in:
TrueZhuanjia
2025-10-29 09:36:16 +08:00
parent a9f4db52b5
commit ff230b3433
2 changed files with 8 additions and 5 deletions
+5 -2
View File
@@ -185,11 +185,14 @@ public class MicHandler: NSObject {
private func configureSession() throws {
let session = AVAudioSession.sharedInstance()
/*
let bluetoothAudioOption = self.useBuiltinMic ? AVAudioSession.CategoryOptions.allowBluetoothA2DP : AVAudioSession.CategoryOptions.allowBluetooth
try session.setCategory(.playAndRecord, mode: .default, options: [.mixWithOthers, .defaultToSpeaker, bluetoothAudioOption])
if #available(iOS 13.0, *) {
try session.setAllowHapticsAndSystemSoundsDuringRecording(true)
}
} */
// AVAudioSession Initiailized in Connection.m -> ArInit
// 列出所有可用输入
if self.useBuiltinMic, let inputs = session.availableInputs {
@@ -201,7 +204,7 @@ public class MicHandler: NSObject {
}
}
}
try session.setActive(true)
// try session.setActive(true)
}
private func sendOpusFrameFromDequeBuffer() {
+3 -3
View File
@@ -284,9 +284,8 @@ int ArInit(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusConfig, v
// Start playback
SDL_PauseAudioDevice(audioDevice, 0);
// Disable lowering volume of other audio streams (SDL sets AVAudioSessionCategoryOptionDuckOthers by default)
// AVAudioSessionCategoryOptionAllowBluetoothA2DP
// AVAudioSessionCategoryOptionAllowBluetooth
// System audio engine initialization
DataManager* dataMan = [[DataManager alloc] init];
TemporarySettings* tempSettings = [dataMan getSettings];
bool useBluetoothD2P = tempSettings.useBuiltinMic || !tempSettings.redirectMic;
@@ -296,6 +295,7 @@ int ArInit(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusConfig, v
mode:AVAudioSessionModeDefault
options:AVAudioSessionCategoryOptionMixWithOthers|AVAudioSessionCategoryOptionDefaultToSpeaker|bluetoothAudioOption
error:nil];
if(tempSettings.redirectMic) if(@available(iOS 13.0, *)) [session setAllowHapticsAndSystemSoundsDuringRecording:YES error:nil];
[session setActive:YES error:nil];
AudioEngineInit(audioConfig.sampleRate, audioConfig.channelCount);