mirror of https://github.com/mpv-player/mpv
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:
parent
b207c1d4a1
commit
3f6be83350
|
@ -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()
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue