From 965ba23303d980c239e2b0191488766cfa7b0f75 Mon Sep 17 00:00:00 2001 From: Akemi Date: Wed, 21 Mar 2018 21:09:05 +0100 Subject: cocoa-cb: render on a dedicated dispatch queue we rendered on the displaylink thread which wasn't the best idea. if rendering took too long or was blocking it also blocked the displaylink callback. when that happened new vsyncs were reported delayed or not at all. consequently the mpv_render_context_report_swap function wasn't called consistently and that could cause bad video playback. so the rendering is moved to a dedicated dispatch queue. furthermore the update callback starts a layer update directly instead of the displaylink callback, making the rendering a bit more consistent. --- video/out/cocoa_cb_common.swift | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'video/out/cocoa_cb_common.swift') diff --git a/video/out/cocoa_cb_common.swift b/video/out/cocoa_cb_common.swift index e8d8bb44f4..659f9f84ce 100644 --- a/video/out/cocoa_cb_common.swift +++ b/video/out/cocoa_cb_common.swift @@ -86,7 +86,7 @@ class CocoaCB: NSObject { } else { layer.setVideo(true) updateWindowSize() - layer.neededFlips += 1 + layer.update() } } @@ -150,7 +150,7 @@ class CocoaCB: NSObject { flagsOut: UnsafeMutablePointer, displayLinkContext: UnsafeMutableRawPointer?) -> CVReturn in let ccb: CocoaCB = MPVHelper.bridge(ptr: displayLinkContext!) - ccb.layer.reportFlip() + ccb.mpv.reportRenderFlip() return kCVReturnSuccess } @@ -160,7 +160,7 @@ class CocoaCB: NSObject { CVDisplayLinkSetCurrentCGDisplay(link!, displayId) if #available(macOS 10.12, *) { CVDisplayLinkSetOutputHandler(link!) { link, now, out, inFlags, outFlags -> CVReturn in - self.layer.reportFlip() + self.mpv.reportRenderFlip() return kCVReturnSuccess } } else { @@ -454,6 +454,7 @@ class CocoaCB: NSObject { func shutdown(_ destroy: Bool = false) { setCursorVisiblility(true) + layer.setVideo(false) stopDisplaylink() uninitLightSensor() removeDisplayReconfigureObserver() -- cgit v1.2.3