summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--osdep/macOS_mpv_helper.swift5
-rw-r--r--video/out/cocoa-cb/window.swift2
-rw-r--r--video/out/cocoa_cb_common.swift22
3 files changed, 21 insertions, 8 deletions
diff --git a/osdep/macOS_mpv_helper.swift b/osdep/macOS_mpv_helper.swift
index db650d792c..5d80e7b5b0 100644
--- a/osdep/macOS_mpv_helper.swift
+++ b/osdep/macOS_mpv_helper.swift
@@ -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
diff --git a/video/out/cocoa-cb/window.swift b/video/out/cocoa-cb/window.swift
index 040cd47751..b296eb25c8 100644
--- a/video/out/cocoa-cb/window.swift
+++ b/video/out/cocoa-cb/window.swift
@@ -306,7 +306,7 @@ class Window: NSWindow, NSWindowDelegate {
isAnimating = false
cocoaCB.layer.neededFlips += 1
- cocoaCB.isShuttingDown = false
+ cocoaCB.checkShutdown()
}
func setToFullScreen() {
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)