From 52da78912bae8e8af12951d692c9e295edf4726a Mon Sep 17 00:00:00 2001 From: kintan Date: Sun, 5 Nov 2023 20:20:24 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3AirPods=20=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/KSPlayer/AVPlayer/KSOptions.swift | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Sources/KSPlayer/AVPlayer/KSOptions.swift b/Sources/KSPlayer/AVPlayer/KSOptions.swift index 7792d3ba5..eb15e6984 100644 --- a/Sources/KSPlayer/AVPlayer/KSOptions.swift +++ b/Sources/KSPlayer/AVPlayer/KSOptions.swift @@ -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 }