From 31ee350cce87463217d8bf781a31775008fa7f65 Mon Sep 17 00:00:00 2001 From: Akemi Date: Wed, 14 Feb 2018 16:42:15 +0100 Subject: 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 --- video/out/cocoa_cb_common.swift | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'video') 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, + inOutputTime: UnsafePointer, + flagsIn: CVOptionFlags, + flagsOut: UnsafeMutablePointer, + 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!) } -- cgit v1.2.3