cocoa-cb: synchronise the flush with the render

this could lead to a crash on deinit when flush
was called while the opengl state was cleaned up.

Fixes #6323
This commit is contained in:
Akemi 2018-11-17 13:12:01 +01:00 committed by Jan Ekström
parent b207c1d4a1
commit 3f6be83350
2 changed files with 6 additions and 4 deletions

View File

@ -128,7 +128,7 @@ class MPVHelper: NSObject {
return flags & UInt64(MPV_RENDER_UPDATE_FRAME.rawValue) > 0
}
func drawRender(_ surface: NSSize, skip: Bool = false) {
func drawRender(_ surface: NSSize, _ ctx: CGLContextObj, skip: Bool = false) {
deinitLock.lock()
if mpvRenderContext != nil {
var i: GLint = 0
@ -154,6 +154,9 @@ class MPVHelper: NSObject {
glClearColor(0, 0, 0, 1)
glClear(GLbitfield(GL_COLOR_BUFFER_BIT))
}
if !skip { CGLFlushDrawable(ctx) }
deinitLock.unlock()
}

View File

@ -110,8 +110,7 @@ class VideoLayer: CAOpenGLLayer {
}
updateSurfaceSize()
mpv.drawRender(surfaceSize!)
CGLFlushDrawable(ctx)
mpv.drawRender(surfaceSize!, ctx)
if needsICCUpdate {
needsICCUpdate = false
@ -244,7 +243,7 @@ class VideoLayer: CAOpenGLLayer {
if isUpdate && needsFlip {
CGLSetCurrentContext(cglContext!)
if mpv.isRenderUpdateFrame() {
mpv.drawRender(NSZeroSize, skip: true)
mpv.drawRender(NSZeroSize, cglContext!, skip: true)
}
}
displayLock.unlock()