summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
authorder richter <der.richter@gmx.de>2024-03-23 22:27:21 +0100
committerder richter <der.richter@gmx.de>2024-03-24 23:03:48 +0100
commit5ab30609616aee2c8e8a03addb05bd0914940a68 (patch)
tree9033babbc08e7d576134fec79b668ccacd62a54e /video/out
parent2a4bf7ca22e0513d7ad0f9072e1877d891e182ac (diff)
downloadmpv-5ab30609616aee2c8e8a03addb05bd0914940a68.tar.bz2
mpv-5ab30609616aee2c8e8a03addb05bd0914940a68.tar.xz
cocoa-cb: use EventHelper for event handling
Diffstat (limited to 'video/out')
-rw-r--r--video/out/cocoa_cb_common.swift12
1 files changed, 4 insertions, 8 deletions
diff --git a/video/out/cocoa_cb_common.swift b/video/out/cocoa_cb_common.swift
index 7ac0f35096..3426ca6cf8 100644
--- a/video/out/cocoa_cb_common.swift
+++ b/video/out/cocoa_cb_common.swift
@@ -17,7 +17,7 @@
import Cocoa
-class CocoaCB: Common {
+class CocoaCB: Common, EventSubscriber {
var libmpv: LibmpvHelper
var layer: GLLayer?
@@ -37,6 +37,7 @@ class CocoaCB: Common {
libmpv = LibmpvHelper(mpvHandle, newlog)
super.init(option, newlog)
layer = GLLayer(cocoaCB: self)
+ AppHub.shared.event?.subscribe(self, event: .init(name: "MPV_EVENT_SHUTDOWN"))
}
func preinit(_ vo: UnsafeMutablePointer<vo>) {
@@ -221,12 +222,7 @@ class CocoaCB: Common {
}
}
- @objc func processEvent(_ event: UnsafePointer<mpv_event>) {
- switch event.pointee.event_id {
- case MPV_EVENT_SHUTDOWN:
- shutdown()
- default:
- break
- }
+ func handle(event: EventHelper.Event) {
+ if event.name == String(describing: MPV_EVENT_SHUTDOWN) { shutdown() }
}
}