refactor audio engine init to Connection.m
This commit is contained in:
1 parent
a9f4db52b5
commit
ff230b3433
2 files changed
+8
-5
No files matched your search
@@ -185,11 +185,14 @@ public class MicHandler: NSObject {
|
|||||||
|
|
||||||
private func configureSession() throws {
|
private func configureSession() throws {
|
||||||
let session = AVAudioSession.sharedInstance()
|
let session = AVAudioSession.sharedInstance()
|
||||||
|
/*
|
||||||
let bluetoothAudioOption = self.useBuiltinMic ? AVAudioSession.CategoryOptions.allowBluetoothA2DP : AVAudioSession.CategoryOptions.allowBluetooth
|
let bluetoothAudioOption = self.useBuiltinMic ? AVAudioSession.CategoryOptions.allowBluetoothA2DP : AVAudioSession.CategoryOptions.allowBluetooth
|
||||||
try session.setCategory(.playAndRecord, mode: .default, options: [.mixWithOthers, .defaultToSpeaker, bluetoothAudioOption])
|
try session.setCategory(.playAndRecord, mode: .default, options: [.mixWithOthers, .defaultToSpeaker, bluetoothAudioOption])
|
||||||
|
|
||||||
if #available(iOS 13.0, *) {
|
if #available(iOS 13.0, *) {
|
||||||
try session.setAllowHapticsAndSystemSoundsDuringRecording(true)
|
try session.setAllowHapticsAndSystemSoundsDuringRecording(true)
|
||||||
}
|
} */
|
||||||
|
// AVAudioSession Initiailized in Connection.m -> ArInit
|
||||||
|
|
||||||
// 列出所有可用输入
|
// 列出所有可用输入
|
||||||
if self.useBuiltinMic, let inputs = session.availableInputs {
|
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() {
|
private func sendOpusFrameFromDequeBuffer() {
|
||||||
|
|||||||
@@ -284,9 +284,8 @@ int ArInit(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusConfig, v
|
|||||||
// Start playback
|
// Start playback
|
||||||
SDL_PauseAudioDevice(audioDevice, 0);
|
SDL_PauseAudioDevice(audioDevice, 0);
|
||||||
|
|
||||||
// Disable lowering volume of other audio streams (SDL sets AVAudioSessionCategoryOptionDuckOthers by default)
|
|
||||||
// AVAudioSessionCategoryOptionAllowBluetoothA2DP
|
// System audio engine initialization
|
||||||
// AVAudioSessionCategoryOptionAllowBluetooth
|
|
||||||
DataManager* dataMan = [[DataManager alloc] init];
|
DataManager* dataMan = [[DataManager alloc] init];
|
||||||
TemporarySettings* tempSettings = [dataMan getSettings];
|
TemporarySettings* tempSettings = [dataMan getSettings];
|
||||||
bool useBluetoothD2P = tempSettings.useBuiltinMic || !tempSettings.redirectMic;
|
bool useBluetoothD2P = tempSettings.useBuiltinMic || !tempSettings.redirectMic;
|
||||||
@@ -296,6 +295,7 @@ int ArInit(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusConfig, v
|
|||||||
mode:AVAudioSessionModeDefault
|
mode:AVAudioSessionModeDefault
|
||||||
options:AVAudioSessionCategoryOptionMixWithOthers|AVAudioSessionCategoryOptionDefaultToSpeaker|bluetoothAudioOption
|
options:AVAudioSessionCategoryOptionMixWithOthers|AVAudioSessionCategoryOptionDefaultToSpeaker|bluetoothAudioOption
|
||||||
error:nil];
|
error:nil];
|
||||||
|
if(tempSettings.redirectMic) if(@available(iOS 13.0, *)) [session setAllowHapticsAndSystemSoundsDuringRecording:YES error:nil];
|
||||||
[session setActive:YES error:nil];
|
[session setActive:YES error:nil];
|
||||||
|
|
||||||
AudioEngineInit(audioConfig.sampleRate, audioConfig.channelCount);
|
AudioEngineInit(audioConfig.sampleRate, audioConfig.channelCount);
|
||||||
|
|||||||
Reference in new issue
Block a user