Commit 4c2c58f2 by pierce

修复连麦声音问题

parent 5df38f0e
......@@ -577,30 +577,32 @@ NSString * const kLiveLinkMicRoleDidChanged = @"linkMicRoleChange";
- (void)delayUpdateToSpeakerPlay {
AVAudioSessionCategoryOptions currentCategoryOptions = [AVAudioSession sharedInstance].categoryOptions;
[self.agoraEngine setEnableSpeakerphone:YES];
currentCategoryOptions = [AVAudioSession sharedInstance].categoryOptions;
AVAudioSessionCategory currentCategory = [AVAudioSession sharedInstance].category;
AVAudioSessionCategoryOptions categoryOptions = AVAudioSessionCategoryOptionMixWithOthers | AVAudioSessionCategoryOptionAllowBluetooth | AVAudioSessionCategoryOptionDefaultToSpeaker | AVAudioSessionCategoryOptionAllowBluetoothA2DP;
NSError *error;
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:categoryOptions error:&error];
AVAudioSessionRouteDescription *currentRoute = [AVAudioSession sharedInstance].currentRoute;
BOOL needForceToSpeaker = NO;
for (AVAudioSessionPortDescription *port in currentRoute.outputs) {
/// 连麦不通过听筒播放
if (port.portType == AVAudioSessionPortBuiltInReceiver) {
needForceToSpeaker = YES;
dispatch_async(dispatch_get_global_queue(0, 0), ^{
AVAudioSessionCategoryOptions currentCategoryOptions = [AVAudioSession sharedInstance].categoryOptions;
[self->_agoraEngine setEnableSpeakerphone:YES];
AVAudioSessionCategoryOptions categoryOptions = 43;
NSError *error;
if (currentCategoryOptions < categoryOptions) {
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:categoryOptions error:&error];
}
}
if (needForceToSpeaker) {
[[AVAudioSession sharedInstance] overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:nil];
}
[[AVAudioSession sharedInstance] setActive:YES error:nil];
currentCategoryOptions = [AVAudioSession sharedInstance].categoryOptions;
AVAudioSessionRouteDescription *currentRoute = [AVAudioSession sharedInstance].currentRoute;
BOOL needForceToSpeaker = NO;
for (AVAudioSessionPortDescription *port in currentRoute.outputs) {
/// 连麦不通过听筒播放
if (port.portType == AVAudioSessionPortBuiltInReceiver) {
needForceToSpeaker = YES;
}
}
if (needForceToSpeaker) {
[[AVAudioSession sharedInstance] overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:nil];
}
[[AVAudioSession sharedInstance] setActive:YES error:nil];
currentCategoryOptions = [AVAudioSession sharedInstance].categoryOptions;
});
}
#pragma mark - AgoraVideoFrameDelegate
- (BOOL)onRenderVideoFrame:(AgoraOutputVideoFrame *)videoFrame uid:(NSUInteger)uid channelId:(NSString *)channelId {
if (uid == FUSLiveHelper.shareInstance.roomInfoModel.roomId.integerValue &&
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment