mirror of
https://github.com/mpv-player/mpv
synced 2025-02-03 13:41:49 +00:00
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:
parent
fbcf2bf207
commit
af7b412d1c
@ -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
|
||||
|
@ -306,7 +306,7 @@ class Window: NSWindow, NSWindowDelegate {
|
||||
|
||||
isAnimating = false
|
||||
cocoaCB.layer.neededFlips += 1
|
||||
cocoaCB.isShuttingDown = false
|
||||
cocoaCB.checkShutdown()
|
||||
}
|
||||
|
||||
func setToFullScreen() {
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user