summaryrefslogtreecommitdiffstats
path: root/video/out/cocoa_cb_common.swift
diff options
context:
space:
mode:
authorAkemi <der.richter@gmx.de>2018-03-21 21:09:05 +0100
committerKevin Mitchell <kevmitch@gmail.com>2018-03-25 16:24:23 -0700
commit965ba23303d980c239e2b0191488766cfa7b0f75 (patch)
tree752b6823e0668bf8eb4fbf4ef6aee10c2fe47591 /video/out/cocoa_cb_common.swift
parent9975835bdeec3f2b04b136ef40c70b02487bb0e6 (diff)
downloadmpv-965ba23303d980c239e2b0191488766cfa7b0f75.tar.bz2
mpv-965ba23303d980c239e2b0191488766cfa7b0f75.tar.xz
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.
Diffstat (limited to 'video/out/cocoa_cb_common.swift')
-rw-r--r--video/out/cocoa_cb_common.swift7
1 files changed, 4 insertions, 3 deletions
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<CVOptionFlags>,
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()