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
17 17
18#pragma once18#pragma once
19 19
20#include <AvailabilityMacros.h>
20#include "config.h"21#include "config.h"
21 22
22#ifndef GL_SILENCE_DEPRECATION23#ifndef GL_SILENCE_DEPRECATION
23#define GL_SILENCE_DEPRECATION24#define GL_SILENCE_DEPRECATION
24#endif25#endif
25 26
26#if !HAVE_MACOS_12_FEATURES27#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)
27#define kAudioObjectPropertyElementMain kAudioObjectPropertyElementMaster32#define kAudioObjectPropertyElementMain kAudioObjectPropertyElementMaster
28#endif33#endif
osdep/mac/swift_compat.swift+0−4
@@ -44,10 +44,6 @@ extension NSDraggingInfo { · 43 unmodified lines
44}44}
45#endif45#endif
46 46
47#if !HAVE_MACOS_12_FEATURES
48let kIOMainPortDefault: mach_port_t = kIOMasterPortDefault
49#endif
50
51#if !HAVE_MACOS_12_FEATURES && HAVE_MACOS_11_FEATURES47#if !HAVE_MACOS_12_FEATURES && HAVE_MACOS_11_FEATURES
52@available(macOS 11.0, *)48@available(macOS 11.0, *)
53extension CGColorSpace {49extension CGColorSpace {
video/out/mac/common.swift+5−2
@@ -281,13 +281,16 @@ class Common: NSObject { · 280 unmodified lines
281 }281 }
282 282
283 func initLightSensor() {283 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"))
285 if srv == IO_OBJECT_NULL {288 if srv == IO_OBJECT_NULL {
286 log.verbose("Can't find an ambient light sensor")289 log.verbose("Can't find an ambient light sensor")
287 return290 return
288 }291 }
289 292
290 lightSensorIOPort = IONotificationPortCreate(kIOMainPortDefault)293 lightSensorIOPort = IONotificationPortCreate(mainPort)
291 IONotificationPortSetDispatchQueue(lightSensorIOPort, queue)294 IONotificationPortSetDispatchQueue(lightSensorIOPort, queue)
292 var n = io_object_t()295 var n = io_object_t()
293 IOServiceAddInterestNotification(lightSensorIOPort, srv, kIOGeneralInterest, lightSensorCallback,296 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