perf: compact [propId, value] wire format for property events

This commit is contained in:
edde746
2026-02-16 15:40:52 +01:00
parent c3b10d6c45
commit a61fca0588
15 changed files with 193 additions and 91 deletions
@@ -98,11 +98,48 @@ class MpvPlayerCore: NSObject {
return false
}
// Register for fullscreen notifications to avoid MoltenVK swapchain crash
let nc = NotificationCenter.default
nc.addObserver(self, selector: #selector(windowWillEnterFullScreen),
name: NSWindow.willEnterFullScreenNotification, object: window)
nc.addObserver(self, selector: #selector(windowDidEnterFullScreen),
name: NSWindow.didEnterFullScreenNotification, object: window)
nc.addObserver(self, selector: #selector(windowWillExitFullScreen),
name: NSWindow.willExitFullScreenNotification, object: window)
nc.addObserver(self, selector: #selector(windowDidExitFullScreen),
name: NSWindow.didExitFullScreenNotification, object: window)
isInitialized = true
print("[MpvPlayerCore] Initialized successfully with MPV")
return true
}
// MARK: - Fullscreen Transition Handling
@objc private func windowWillEnterFullScreen(_ notification: Notification) {
guard mpv != nil else { return }
print("[MpvPlayerCore] willEnterFullScreen — disabling video output")
mpv_set_property_string(mpv, "vid", "no")
}
@objc private func windowDidEnterFullScreen(_ notification: Notification) {
guard mpv != nil else { return }
print("[MpvPlayerCore] didEnterFullScreen — re-enabling video output")
mpv_set_property_string(mpv, "vid", "auto")
}
@objc private func windowWillExitFullScreen(_ notification: Notification) {
guard mpv != nil else { return }
print("[MpvPlayerCore] willExitFullScreen — disabling video output")
mpv_set_property_string(mpv, "vid", "no")
}
@objc private func windowDidExitFullScreen(_ notification: Notification) {
guard mpv != nil else { return }
print("[MpvPlayerCore] didExitFullScreen — re-enabling video output")
mpv_set_property_string(mpv, "vid", "auto")
}
private func setupMpv() -> Bool {
guard let metalLayer = metalLayer else { return false }
@@ -508,6 +545,8 @@ class MpvPlayerCore: NSObject {
// MARK: - Cleanup
func dispose() {
NotificationCenter.default.removeObserver(self)
// Cancel any pending async commands
pendingCommandsLock.lock()
let pending = pendingCommands