Commit 4c2c58f2 by pierce

修复连麦声音问题

parent 5df38f0e
...@@ -577,13 +577,15 @@ NSString * const kLiveLinkMicRoleDidChanged = @"linkMicRoleChange"; ...@@ -577,13 +577,15 @@ NSString * const kLiveLinkMicRoleDidChanged = @"linkMicRoleChange";
- (void)delayUpdateToSpeakerPlay { - (void)delayUpdateToSpeakerPlay {
dispatch_async(dispatch_get_global_queue(0, 0), ^{
AVAudioSessionCategoryOptions currentCategoryOptions = [AVAudioSession sharedInstance].categoryOptions; AVAudioSessionCategoryOptions currentCategoryOptions = [AVAudioSession sharedInstance].categoryOptions;
[self.agoraEngine setEnableSpeakerphone:YES]; [self->_agoraEngine setEnableSpeakerphone:YES];
currentCategoryOptions = [AVAudioSession sharedInstance].categoryOptions; AVAudioSessionCategoryOptions categoryOptions = 43;
AVAudioSessionCategory currentCategory = [AVAudioSession sharedInstance].category;
AVAudioSessionCategoryOptions categoryOptions = AVAudioSessionCategoryOptionMixWithOthers | AVAudioSessionCategoryOptionAllowBluetooth | AVAudioSessionCategoryOptionDefaultToSpeaker | AVAudioSessionCategoryOptionAllowBluetoothA2DP;
NSError *error; NSError *error;
if (currentCategoryOptions < categoryOptions) {
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:categoryOptions error:&error]; [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:categoryOptions error:&error];
}
AVAudioSessionRouteDescription *currentRoute = [AVAudioSession sharedInstance].currentRoute; AVAudioSessionRouteDescription *currentRoute = [AVAudioSession sharedInstance].currentRoute;
BOOL needForceToSpeaker = NO; BOOL needForceToSpeaker = NO;
for (AVAudioSessionPortDescription *port in currentRoute.outputs) { for (AVAudioSessionPortDescription *port in currentRoute.outputs) {
...@@ -598,9 +600,9 @@ NSString * const kLiveLinkMicRoleDidChanged = @"linkMicRoleChange"; ...@@ -598,9 +600,9 @@ NSString * const kLiveLinkMicRoleDidChanged = @"linkMicRoleChange";
} }
[[AVAudioSession sharedInstance] setActive:YES error:nil]; [[AVAudioSession sharedInstance] setActive:YES error:nil];
currentCategoryOptions = [AVAudioSession sharedInstance].categoryOptions; currentCategoryOptions = [AVAudioSession sharedInstance].categoryOptions;
});
} }
#pragma mark - AgoraVideoFrameDelegate #pragma mark - AgoraVideoFrameDelegate
- (BOOL)onRenderVideoFrame:(AgoraOutputVideoFrame *)videoFrame uid:(NSUInteger)uid channelId:(NSString *)channelId { - (BOOL)onRenderVideoFrame:(AgoraOutputVideoFrame *)videoFrame uid:(NSUInteger)uid channelId:(NSString *)channelId {
if (uid == FUSLiveHelper.shareInstance.roomInfoModel.roomId.integerValue && 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