Trim comments and hoist settings read in stream filtering

Drop comments restating what the code shows; hoist allowSoftwareDecodedFormats
out of the recommendedVideoStreams filter closure so the bridge property is
read once per render instead of once per stream.
This commit is contained in:
Arkadiusz Fal
2026-05-07 18:03:34 +02:00
parent 16477641ab
commit 158d518e3a
4 changed files with 5 additions and 15 deletions

View File

@@ -75,9 +75,6 @@ extension SettingsManager {
}
}
/// When enabled, the auto stream selector will consider video formats whose codec
/// is not hardware-decodable on this device. Disabled by default. Useful on Apple TV
/// where 4K VP9/AV1 is otherwise excluded from auto-selection.
var allowSoftwareDecodedFormats: Bool {
get {
if let cached = _allowSoftwareDecodedFormats { return cached }

View File

@@ -1907,11 +1907,9 @@ final class PlayerService {
}
// Filter out codecs with priority 0 (software decode) if hardware options exist,
// unless the user opted in to software-decoded formats (e.g. to unlock 4K VP9/AV1
// on Apple TV models without hardware decoders for those codecs).
let allowSoftware = settingsManager?.allowSoftwareDecodedFormats ?? false
// unless the user opted in to software-decoded formats.
let streamsToConsider: [Stream]
if allowSoftware {
if settingsManager?.allowSoftwareDecodedFormats ?? false {
streamsToConsider = filteredVideoStreams
} else {
let hardwareDecodableStreams = filteredVideoStreams.filter { videoCodecPriority($0.videoCodec) > 0 }

View File

@@ -91,19 +91,16 @@ extension QualitySelectorView {
return downloadedStreams + onlineVideoStreams
}
/// Recommended video streams (hardware-decodable codecs).
/// When `allowSoftwareDecodedFormats` is ON, all video streams are considered recommended.
var recommendedVideoStreams: [Stream] {
videoStreams.filter { (stream: Stream) -> Bool in
let allowSoftware = allowSoftwareDecodedFormats
return videoStreams.filter { (stream: Stream) -> Bool in
if stream.url.isFileURL { return true }
if stream.isMuxed { return true }
if allowSoftwareDecodedFormats { return true }
if allowSoftware { return true }
return !requiresSoftwareDecode(stream.videoCodec)
}
}
/// Other video streams (software decode required).
/// Empty when `allowSoftwareDecodedFormats` is ON those streams are now recommended.
var otherVideoStreams: [Stream] {
if allowSoftwareDecodedFormats { return [] }
return videoStreams.filter { (stream: Stream) -> Bool in

View File

@@ -71,8 +71,6 @@ struct QualitySelectorView: View {
appEnvironment?.settingsManager.showAdvancedStreamDetails ?? false
}
/// Whether the user has opted in to software-decoded formats during auto-selection.
/// When enabled, software-decoded streams are treated as recommended (no split).
var allowSoftwareDecodedFormats: Bool {
appEnvironment?.settingsManager.allowSoftwareDecodedFormats ?? false
}