diff options
-rw-r--r-- | video/out/cocoa_cb_common.swift | 2 | ||||
-rw-r--r-- | video/out/mac/gl_layer.swift | 10 |
2 files changed, 12 insertions, 0 deletions
diff --git a/video/out/cocoa_cb_common.swift b/video/out/cocoa_cb_common.swift index 4655cabf9b..094dab1a55 100644 --- a/video/out/cocoa_cb_common.swift +++ b/video/out/cocoa_cb_common.swift @@ -209,7 +209,9 @@ class CocoaCB: Common { uninit() uninitCommon() + layer?.lockCglContext() libmpv.deinitRender() + layer?.unlockCglContext() libmpv.deinitMPV(destroy) } diff --git a/video/out/mac/gl_layer.swift b/video/out/mac/gl_layer.swift index dd96af7265..d0d3a6de16 100644 --- a/video/out/mac/gl_layer.swift +++ b/video/out/mac/gl_layer.swift @@ -199,6 +199,14 @@ class GLLayer: CAOpenGLLayer { } } + func lockCglContext() { + CGLLockContext(cglContext) + } + + func unlockCglContext() { + CGLUnlockContext(cglContext) + } + override func copyCGLPixelFormat(forDisplayMask mask: UInt32) -> CGLPixelFormatObj { return cglPixelFormat } @@ -219,10 +227,12 @@ class GLLayer: CAOpenGLLayer { super.display() CATransaction.flush() if isUpdate && needsFlip { + lockCglContext() CGLSetCurrentContext(cglContext) if libmpv.isRenderUpdateFrame() { libmpv.drawRender(NSZeroSize, bufferDepth, cglContext, skip: true) } + unlockCglContext() } displayLock.unlock() } |