From 6f009a91a6da8cd983911b890678db80b1fd40b3 Mon Sep 17 00:00:00 2001 From: der richter Date: Wed, 30 Oct 2024 22:08:34 +0100 Subject: [PATCH] mac/common: fix light sensor deprecations --- osdep/mac/swift_compat.swift | 4 ++++ video/out/mac/common.swift | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/osdep/mac/swift_compat.swift b/osdep/mac/swift_compat.swift index 24365cdd4a..9b72a4828b 100644 --- a/osdep/mac/swift_compat.swift +++ b/osdep/mac/swift_compat.swift @@ -44,6 +44,10 @@ extension NSDraggingInfo { } #endif +#if !HAVE_MACOS_12_FEATURES +let kIOMainPortDefault: mach_port_t = kIOMasterPortDefault +#endif + #if !HAVE_MACOS_12_FEATURES && HAVE_MACOS_11_FEATURES @available(macOS 11.0, *) extension CGColorSpace { diff --git a/video/out/mac/common.swift b/video/out/mac/common.swift index b4ef836501..5af87e15cb 100644 --- a/video/out/mac/common.swift +++ b/video/out/mac/common.swift @@ -281,13 +281,13 @@ class Common: NSObject { } func initLightSensor() { - let srv = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("AppleLMUController")) + let srv = IOServiceGetMatchingService(kIOMainPortDefault, IOServiceMatching("AppleLMUController")) if srv == IO_OBJECT_NULL { log.verbose("Can't find an ambient light sensor") return } - lightSensorIOPort = IONotificationPortCreate(kIOMasterPortDefault) + lightSensorIOPort = IONotificationPortCreate(kIOMainPortDefault) IONotificationPortSetDispatchQueue(lightSensorIOPort, queue) var n = io_object_t() IOServiceAddInterestNotification(lightSensorIOPort, srv, kIOGeneralInterest, lightSensorCallback,