refactor audio engine init to Connection.m
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user