summaryrefslogtreecommitdiffstats
path: root/video/out/cocoa_cb_common.swift
diff options
context:
space:
mode:
Diffstat (limited to 'video/out/cocoa_cb_common.swift')
-rw-r--r--video/out/cocoa_cb_common.swift22
1 files changed, 16 insertions, 6 deletions
diff --git a/video/out/cocoa_cb_common.swift b/video/out/cocoa_cb_common.swift
index b5ba9ee0c8..e8d8bb44f4 100644
--- a/video/out/cocoa_cb_common.swift
+++ b/video/out/cocoa_cb_common.swift
@@ -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)