From e548bda73a1a75be1c6eeec1b5085805e0a0db25 Mon Sep 17 00:00:00 2001 From: TrueZhuanjia Date: Thu, 30 Oct 2025 21:35:27 +0800 Subject: [PATCH] stereo to system audio engine, multi-channel audio to SDL --- VoidLink/Stream/Connection.m | 5 ++--- VoidLink/ViewControllers/SettingsViewController.m | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/VoidLink/Stream/Connection.m b/VoidLink/Stream/Connection.m index 4d654644..a3e4647c 100644 --- a/VoidLink/Stream/Connection.m +++ b/VoidLink/Stream/Connection.m @@ -290,11 +290,10 @@ int ArInit(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusConfig, v TemporarySettings* tempSettings = [dataMan getSettings]; bool useBluetoothD2P = tempSettings.useBuiltinMic || !tempSettings.redirectMic; AVAudioSessionCategoryOptions bluetoothAudioOption = useBluetoothD2P ? AVAudioSessionCategoryOptionAllowBluetoothA2DP : AVAudioSessionCategoryOptionAllowBluetooth; - AVAudioSessionCategoryOptions audioMixOption = opusConfig->channelCount > 2 ? 0 : AVAudioSessionCategoryOptionMixWithOthers; AVAudioSession *session = [AVAudioSession sharedInstance]; [session setCategory:tempSettings.redirectMic ? AVAudioSessionCategoryPlayAndRecord : AVAudioSessionCategoryPlayback mode:AVAudioSessionModeDefault - options:audioMixOption|AVAudioSessionCategoryOptionDefaultToSpeaker|bluetoothAudioOption + options:AVAudioSessionCategoryOptionMixWithOthers|AVAudioSessionCategoryOptionDefaultToSpeaker|bluetoothAudioOption error:nil]; if(tempSettings.redirectMic) if(@available(iOS 13.0, *)) [session setAllowHapticsAndSystemSoundsDuringRecording:YES error:nil]; [session setActive:YES error:nil]; @@ -411,7 +410,7 @@ void ArDecodeAndPlaySample(char* sampleData, int sampleLength) float* fbuf = (float*)audioBuffer; - if(useSystemAudioEngine) { + if(audioConfig.channelCount <= 2) { // 创建 AVAudioPCMBuffer AVAudioFrameCount frameCount = decodeLen; AVAudioPCMBuffer *buffer = [[AVAudioPCMBuffer alloc] initWithPCMFormat:audioFormat frameCapacity:frameCount]; diff --git a/VoidLink/ViewControllers/SettingsViewController.m b/VoidLink/ViewControllers/SettingsViewController.m index 074e62a9..93e67b5d 100644 --- a/VoidLink/ViewControllers/SettingsViewController.m +++ b/VoidLink/ViewControllers/SettingsViewController.m @@ -790,7 +790,8 @@ BOOL isCustomResolution(int resolutionSelected) { [self addSetting:self.redirectMicStack ofId:@"redirectMicStack" withInfoTag:YES withDynamicLabel:NO to:audioSection]; [self addSetting:self.useBuiltinMicStack ofId:@"useBuiltinMicStack" withInfoTag:YES withDynamicLabel:NO to:audioSection]; [self addSetting:self.micVolumeStack ofId:@"micVolumeStack" withInfoTag:NO withDynamicLabel:YES to:audioSection]; - [self addSetting:self.audioEngineStack ofId:@"audioEngineStack" withInfoTag:YES withDynamicLabel:NO to:audioSection]; + // [self addSetting:self.audioEngineStack ofId:@"audioEngineStack" withInfoTag:YES withDynamicLabel:NO to:audioSection]; + // cancel audio engine selector due to system engine is unable to playback multi-channel audio [self addSetting:self.audioConfigStack ofId:@"audioConfigStack" withInfoTag:NO withDynamicLabel:NO to:audioSection]; [audioSection addToParentStack:_parentStack]; // [audioSection setExpanded:NO];