This commit is contained in:
2026-01-21 17:59:12 +08:00
parent 36c0b0b210
commit 06a572c08a
4 changed files with 93 additions and 2 deletions

View File

@@ -141,7 +141,7 @@
// +
// Category: PlayAndRecord -
// Mode: VoiceChat -
// Mode: VoiceChat - AGC/
// Options:
// - DefaultToSpeaker: 使
// - AllowBluetooth:
@@ -162,6 +162,31 @@
return NO;
}
// 使
NSError *sampleRateError = nil;
[session setPreferredSampleRate:16000 error:&sampleRateError];
if (sampleRateError) {
NSLog(@"[AudioSessionManager] Failed to set sample rate: %@",
sampleRateError.localizedDescription);
}
NSError *bufferError = nil;
[session setPreferredIOBufferDuration:0.02 error:&bufferError];
if (bufferError) {
NSLog(@"[AudioSessionManager] Failed to set IO buffer: %@",
bufferError.localizedDescription);
}
if ([session respondsToSelector:@selector(setPreferredInputNumberOfChannels:
error:)]) {
NSError *channelsError = nil;
[session setPreferredInputNumberOfChannels:1 error:&channelsError];
if (channelsError) {
NSLog(@"[AudioSessionManager] Failed to set input channels: %@",
channelsError.localizedDescription);
}
}
return YES;
}
@@ -206,6 +231,15 @@
return NO;
}
if (session.isInputGainSettable) {
NSError *gainError = nil;
[session setInputGain:1.0 error:&gainError];
if (gainError) {
NSLog(@"[AudioSessionManager] Failed to set input gain: %@",
gainError.localizedDescription);
}
}
self.isSessionActive = YES;
return YES;
}