mirror of
https://github.com/mpv-player/mpv
synced 2025-02-03 05:31:34 +00:00
cocoa-cb: fix drawing on macOS 10.11
the CVDisplayLinkSetOutputHandler function introduced with 10.11 is broken on the very same version of the OS, which caused our render loop never to start. fallback to the old display link callback on 10.11. for reference the radar http://www.openradar.me/26640780 Fixes #5527
This commit is contained in:
parent
6751b5b1c2
commit
31ee350cce
@ -141,13 +141,29 @@ class CocoaCB: NSObject {
|
||||
}
|
||||
}
|
||||
|
||||
let linkCallback: CVDisplayLinkOutputCallback = {
|
||||
(displayLink: CVDisplayLink,
|
||||
inNow: UnsafePointer<CVTimeStamp>,
|
||||
inOutputTime: UnsafePointer<CVTimeStamp>,
|
||||
flagsIn: CVOptionFlags,
|
||||
flagsOut: UnsafeMutablePointer<CVOptionFlags>,
|
||||
displayLinkContext: UnsafeMutableRawPointer?) -> CVReturn in
|
||||
let ccb: CocoaCB = MPVHelper.bridge(ptr: displayLinkContext!)
|
||||
ccb.layer.reportFlip()
|
||||
return kCVReturnSuccess
|
||||
}
|
||||
|
||||
func startDisplayLink() {
|
||||
let displayId = UInt32(window.screen!.deviceDescription["NSScreenNumber"] as! Int)
|
||||
CVDisplayLinkCreateWithActiveCGDisplays(&link)
|
||||
CVDisplayLinkSetCurrentCGDisplay(link!, displayId)
|
||||
CVDisplayLinkSetOutputHandler(link!) { link, now, out, inFlags, outFlags -> CVReturn in
|
||||
self.layer.reportFlip()
|
||||
return kCVReturnSuccess
|
||||
if #available(macOS 10.12, *) {
|
||||
CVDisplayLinkSetOutputHandler(link!) { link, now, out, inFlags, outFlags -> CVReturn in
|
||||
self.layer.reportFlip()
|
||||
return kCVReturnSuccess
|
||||
}
|
||||
} else {
|
||||
CVDisplayLinkSetOutputCallback(link!, linkCallback, MPVHelper.bridge(obj: self))
|
||||
}
|
||||
CVDisplayLinkStart(link!)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user