fix(tvos): make HDR toggle disable Dolby Vision

HDR-off now forces SDR display criteria for DV like it does for HDR10,
and the runtime toggle re-applies the criteria. Refs #1262 (part A).
This commit is contained in:
edde746
2026-06-06 14:17:52 +02:00
parent 1ef4032666
commit 8139fc2b17
2 changed files with 40 additions and 5 deletions
@@ -97,6 +97,7 @@ class MpvPlayerCoreBase: NSObject {
private var cachedVideoPrimaries: String?
private var cachedVideoColorMatrix: String?
private var serverDisplayCriteriaActive = false
private var lastServerCriteria: ServerDisplayCriteria?
private var cachedDvConversionMode = "auto"
private var cachedDvConversionLogEnabled = false
var hdrEnabled: Bool {
@@ -231,6 +232,7 @@ class MpvPlayerCoreBase: NSObject {
func setServerDisplayCriteria(_ criteria: ServerDisplayCriteria?) {
cacheLock.lock()
serverDisplayCriteriaActive = criteria != nil
lastServerCriteria = criteria
cacheLock.unlock()
let apply = { [weak self] in
@@ -278,6 +280,21 @@ class MpvPlayerCoreBase: NSObject {
}
}
/// Re-evaluate the tvOS HDMI display mode using the most recent criteria.
/// On tvOS the HDR toggle only reaches the display through this path, so the
/// runtime toggle calls this to switch DV/HDR SDR without reloading.
func reapplyDisplayCriteria() {
cacheLock.lock()
let criteria = lastServerCriteria
cacheLock.unlock()
if let criteria {
setServerDisplayCriteria(criteria)
} else {
scheduleDisplayCriteriaUpdate()
}
}
func setupMpv() -> Bool {
#if os(macOS)
guard let renderLayer = metalLayer else { return false }
@@ -509,6 +526,15 @@ class MpvPlayerCoreBase: NSObject {
DispatchQueue.main.async {
self.updateEDRMode(sigPeak: sigPeak)
}
// On tvOS the toggle only takes effect through the HDMI display-mode path
// (target-colorspace-hint is inert in the avfoundation VO and EDR is
// iOS-only), so re-evaluate the display criteria with the new flag.
#if os(tvOS)
DispatchQueue.main.async {
self.reapplyDisplayCriteria()
}
#endif
}
/// PiP presents the AVSampleBufferDisplayLayer directly, so subtitles must