diff --git a/VoidLink/Input/MicHandler.swift b/VoidLink/Input/MicHandler.swift index 29a5343b..6bf9a447 100644 --- a/VoidLink/Input/MicHandler.swift +++ b/VoidLink/Input/MicHandler.swift @@ -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() { diff --git a/VoidLink/Stream/Connection.m b/VoidLink/Stream/Connection.m index 544c080b..5aa3284c 100644 --- a/VoidLink/Stream/Connection.m +++ b/VoidLink/Stream/Connection.m @@ -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);