Add nil safety checks for stream resolution handling

Added comprehensive nil checks for stream resolution values across PlayerBackend, QualityProfile, and PlayerQueue to prevent crashes when streams have missing resolution metadata. Also added backend nil checks in PlayerQueue.
This commit is contained in:
Arkadiusz Fal
2025-11-14 18:58:27 +01:00
parent b6df73f949
commit 6511d4c9ba
3 changed files with 40 additions and 9 deletions

View File

@@ -76,8 +76,13 @@ struct QualityProfile: Hashable, Identifiable, Defaults.Serializable {
return true
}
// Safety check: Ensure stream has a resolution
guard let streamResolution = stream.resolution else {
return false
}
let defaultResolution = Stream.Resolution.custom(height: 720, refreshRate: 30)
let resolutionMatch = resolution.value ?? defaultResolution >= stream.resolution
let resolutionMatch = resolution.value ?? defaultResolution >= streamResolution
if resolutionMatch, formats.contains(.stream), stream.kind == .stream {
return true