cocoa-cb: fix shutdown when fullscreen animation is running

commit 2edf00f changed the MPV_EVENT_SHUTDOWN behaviour slightly, such
that it will only be sent once. cocoa-cb relied on it being sent
continuously till all mpv_handles are destroyed. now it manually shuts
down and destroys the mpv_handle after the animation instead of relying
on this removed behaviour.
This commit is contained in:
Akemi 2018-03-16 13:52:15 +01:00 committed by Kevin Mitchell
parent fbcf2bf207
commit af7b412d1c
No known key found for this signature in database
GPG Key ID: 559A34B46A917232
3 changed files with 21 additions and 8 deletions

View File

@ -245,7 +245,10 @@ class MPVHelper: NSObject {
mpvRenderContext = nil
}
func deinitMPV() {
func deinitMPV(_ destroy: Bool = false) {
if destroy {
mpv_destroy(mpvHandle)
}
mpvHandle = nil
mpvLog = nil
inputContext = nil

View File

@ -306,7 +306,7 @@ class Window: NSWindow, NSWindowDelegate {
isAnimating = false
cocoaCB.layer.neededFlips += 1
cocoaCB.isShuttingDown = false
cocoaCB.checkShutdown()
}
func setToFullScreen() {

View File

@ -452,6 +452,21 @@ class CocoaCB: NSObject {
}
}
func shutdown(_ destroy: Bool = false) {
setCursorVisiblility(true)
stopDisplaylink()
uninitLightSensor()
removeDisplayReconfigureObserver()
mpv.deinitRender()
mpv.deinitMPV(destroy)
}
func checkShutdown() {
if isShuttingDown {
shutdown(true)
}
}
func processEvent(_ event: UnsafePointer<mpv_event>) {
switch event.pointee.event_id {
case MPV_EVENT_SHUTDOWN:
@ -459,12 +474,7 @@ class CocoaCB: NSObject {
isShuttingDown = true
return
}
setCursorVisiblility(true)
stopDisplaylink()
uninitLightSensor()
removeDisplayReconfigureObserver()
mpv.deinitRender()
mpv.deinitMPV()
shutdown()
case MPV_EVENT_PROPERTY_CHANGE:
if backendState == .init {
handlePropertyChange(event)