History

mac/compat: fix compatibility for deployment targets lower than SDK ver

the swift parts can't be nicely encapsulated in the compat file because it lags proper target version compile time checks. Fixes #15292

der richter committed 1 year ago

Commit 45c1c581 parent 46574d43 files · +11 −7Browse files

Unified · Split

3 files
  1. osdep/mac/compat.h +6 −1
  2. osdep/mac/swift_compat.swift +0 −4
  3. video/out/mac/common.swift +5 −2
osdep/mac/compat.h+6−1
@@ -17,12 +17,17 @@ · 16 unmodified lines
1717
1818 #pragma once
1919
20+#include <AvailabilityMacros.h>
2021 #include "config.h"
2122
2223 #ifndef GL_SILENCE_DEPRECATION
2324 #define GL_SILENCE_DEPRECATION
2425 #endif
2526
26−#if !HAVE_MACOS_12_FEATURES
27+#ifndef MAC_OS_VERSION_12_0
28+#define MAC_OS_VERSION_12_0 120000
29+#endif
30+
31+#if !HAVE_MACOS_12_FEATURES || (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_VERSION_12_0)
2732 #define kAudioObjectPropertyElementMain kAudioObjectPropertyElementMaster
2833 #endif
osdep/mac/swift_compat.swift+0−4
@@ -44,10 +44,6 @@ extension NSDraggingInfo { · 43 unmodified lines
4444 }
4545 #endif
4646
47−#if !HAVE_MACOS_12_FEATURES
48−let kIOMainPortDefault: mach_port_t = kIOMasterPortDefault
49−#endif
50−
5147 #if !HAVE_MACOS_12_FEATURES && HAVE_MACOS_11_FEATURES
5248 @available(macOS 11.0, *)
5349 extension CGColorSpace {
video/out/mac/common.swift+5−2
@@ -281,13 +281,16 @@ class Common: NSObject { · 280 unmodified lines
281281 }
282282
283283 func initLightSensor() {
284− let srv = IOServiceGetMatchingService(kIOMainPortDefault, IOServiceMatching("AppleLMUController"))
284+ let mainPort: mach_port_t
285+ if #available(macOS 12.0, *) { mainPort = kIOMainPortDefault } else { mainPort = kIOMasterPortDefault }
286+
287+ let srv = IOServiceGetMatchingService(mainPort, IOServiceMatching("AppleLMUController"))
285288 if srv == IO_OBJECT_NULL {
286289 log.verbose("Can't find an ambient light sensor")
287290 return
288291 }
289292
290− lightSensorIOPort = IONotificationPortCreate(kIOMainPortDefault)
293+ lightSensorIOPort = IONotificationPortCreate(mainPort)
291294 IONotificationPortSetDispatchQueue(lightSensorIOPort, queue)
292295 var n = io_object_t()
293296 IOServiceAddInterestNotification(lightSensorIOPort, srv, kIOGeneralInterest, lightSensorCallback,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t