Skip to content

Commit

Permalink
解决AirPods 的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
kingslay committed Nov 5, 2023
1 parent 4ccd39d commit 52da789
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions Sources/KSPlayer/AVPlayer/KSOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -514,14 +514,15 @@ public extension KSOptions {
try? AVAudioSession.sharedInstance().setPreferredOutputNumberOfChannels(Int(minChannels))
KSLog("[audio] set preferredOutputNumberOfChannels: \(minChannels)")
}
// 不要从currentRoute获取maxRouteChannelsCount,有可能会不准。导致多音道设备也返回2(一开始播放一个2声道,就容易出现)
// if !(isUseAudioRenderer && isSpatialAudioEnabled) {
// let maxRouteChannelsCount = AVAudioSession.sharedInstance().currentRoute.outputs.compactMap {
// $0.channels?.count
// }.max() ?? 2
// KSLog("[audio] currentRoute max channels: \(maxRouteChannelsCount)")
if !(isUseAudioRenderer && isSpatialAudioEnabled) {
let maxRouteChannelsCount = AVAudioSession.sharedInstance().currentRoute.outputs.compactMap {
$0.channels?.count
}.max() ?? 2
KSLog("[audio] currentRoute max channels: \(maxRouteChannelsCount)")
// 不要用maxRouteChannelsCount来panduan,有可能会不准。导致多音道设备也返回2(一开始播放一个2声道,就容易出现)
// channelCount = AVAudioChannelCount(min(AVAudioSession.sharedInstance().outputNumberOfChannels, maxRouteChannelsCount))
// }
channelCount = AVAudioChannelCount(AVAudioSession.sharedInstance().outputNumberOfChannels)
}
} else {
channelCount = 2
}
Expand Down

0 comments on commit 52da789

Please sign in to comment.