summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAkemi <der.richter@gmx.de>2018-02-14 16:42:15 +0100
committerKevin Mitchell <kevmitch@gmail.com>2018-02-16 00:48:34 -0800
commit31ee350cce87463217d8bf781a31775008fa7f65 (patch)
tree64b6f42770ff4deddd34f5a7309a712be0cafdb7
parent6751b5b1c2c65fc2c746abe0c8d712541c27f437 (diff)
downloadmpv-31ee350cce87463217d8bf781a31775008fa7f65.tar.bz2
mpv-31ee350cce87463217d8bf781a31775008fa7f65.tar.xz
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
-rw-r--r--video/out/cocoa_cb_common.swift22
1 files changed, 19 insertions, 3 deletions
diff --git a/video/out/cocoa_cb_common.swift b/video/out/cocoa_cb_common.swift
index 9a6da82ecf..0ce06428bd 100644
--- a/video/out/cocoa_cb_common.swift
+++ b/video/out/cocoa_cb_common.swift
@@ -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!)
}